This is just a reference for some commands and techniques that are not used that much and easily forgotten. These should be pretty universally available on OSX, Unix, and Linux.
Command for keeping a queue of directories as you move around
pushd ~/Downloads
pushd ~/Documents
popd #this will take us back to ~/Downloadswhich- figure out where the command executable livesbasename- gives you the last name in a path- Ex:
basename ~/Downloads/some_other_folder/rawr.txtgives rawr.txt - This works for both directories and files
- Ex:
file- gives you details information on files and directories
Compresses a single file
#Transforms rawr.txt => rawr.txt.gz
gzip rawr.txtTo decompress
gzip -d rawr.txt.gzCompressing multiple files
zip someZip.zip list.txt of.txt files.txtUnzipping
unzip someZip.zipHow we do dat?
# create, verbose, gzip, give files now
tar -cvzf archive.tar.gz list.txt of.txt files.txtUntarring
#extract, verbose, gzip, give files now
tar -xvzf archive.tar.gz sort filename.txt #sorts file to stdout
sort -u filename.txt #sort and make lines unique to stdout
cat filename.txt | sort #same as first example
sort filename.txt | unique #same as second example echo "some stuff to copy" | pbcopy #copy some text to clipboard
pbpaste #paste what is in clipboardexpr is good for simple math operations. You do need to escape the parameters that have other meanings (* for example would be *)
expr 1 + 1
expr 1 \* 9Just run the bc command to open up a prompt for math.
uptime- time since last restartdatecal- Show current calendar page for current month OR pass a Month Year to itcal July 1959
wc- get word/line/character countwc -l- get line count
history- get last commands used