Skip to content

Instantly share code, notes, and snippets.

@karlpokus
Last active February 20, 2017 16:41
Show Gist options
  • Save karlpokus/ce674a5894e684cff377f86e95c9207a to your computer and use it in GitHub Desktop.
Save karlpokus/ce674a5894e684cff377f86e95c9207a to your computer and use it in GitHub Desktop.
bash like a baos!
# cd from ls
cd `ls | grep bengt`
# ls by mtime
ls -t
# page through a file
less filename
# processes
top
ps -aux
# write file
echo foo > file
# append to file
echo foo >> file
# list disc usage in pwd
du -sh *
# 10 largest dirs in pwd
du -s * | sort -nr | head
# like above only sort by human-readable size
du -sh * | sort -h
du -sh * | sort -hr | head -n4
# above for os x - who's laking -h
du -sk * | sort -nr | head
# read the docs
man [command]
info [command]
# copy heroku app url (on OS X)
heroku apps:info | grep -i web | pbcopy
# pipe to sort
ls | sort
# sort by num
du /bin/* | sort -n
# sort by column
sort -k 2 file
# sort csv by 2nd col descending
sort -t ',' -k 2 -r data.csv
# exclude first and last line
head -n -1 data.csv | tail -n +2
# random item from input
ls | shuf -n 1
# random line from file
cat data.csv | shuf -n 1
# first/last n lines of all js
[head|tail] -n 2 *.js
# tail and follow file
tail -f file
# extract column(s) from .tsv
cut -f 1[-n] peeps.tsv
# extract column(s) from .csv
cut -d ',' -f 1[-n] data.csv
# crate columns from csv
column -s "," -t data.csv
# line, word and character count of file(s)
wc [-lwc] file
# print calendar data
cal [monthAsNumberOrName] [year]
# include weekNumber for prev, this and next month
ncal -w3
ncal -w -A1 -B1
# fetch and save img
wget [url]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment