cp command
To copy a file
cp ~/Desktop/foo.txt ~/Downloads/foo.txt
To copy a directory
cp -r ~/Desktop/cruise_pics/ ~/Pictures/
To create a copy but ask to overwrite if the destination file already exists
cp -i ~/Desktop/foo.txt ~/Documents/foo.txt
To create a backup file with date
cp foo.txt{,."$(date +%Y%m%d-%H%M%S)"}
cat command
To display the contents of a file
cat <file>
To display file contents with line numbers
cat -n <file>
To display file contents with line numbers (blank lines excluded)
cat -b <file>
tee command
To tee stdout to
ls | tee <outfile>
To tee stdout and append to
ls | tee -a <outfile>
To tee stdout to the terminal, and also pipe it into another program for further processing
ls | tee /dev/tty | xargs printf "\033[1;34m%s\033[m\n"
sort command
To sort a file
sort <file>
To sort a file by keeping only unique
sort -u <file>
To sort a file and reverse the result
sort -r <file>
To sort a file randomly
sort -R <file>