------------------------------------------------------------------------ quirky commands: shuf,rev,tac,look,yes,sl,cowsay,figlet ------------------------------------------------------------------------ ------------------------------------------------------------------------ shuf ------------------------------------------------------------------------ shuf generates random permutations $ shuf <(seq 5) 3 1 2 4 5 $ shuf file will present shuffled lines of the file $ shuf -e hello kitty mitty ditty #shuffle the arguments mitty ditty hello kitty ------------------------------------------------------------------------ rev ------------------------------------------------------------------------ reverse characters of each line of a file $ rev <(echo Hello Kitty) yttiK olleH ------------------------------------------------------------------------ tac ------------------------------------------------------------------------ tac print file with first line last, last line first and so on BSD does not have "tac" (which is "cat" spelt backwords). We will use the GNU "gtac" tool. $ cat InFile 1 A B 2 C D $ gtac Infile D C 2 B A 1 Another way to reverse a file is $ tail -r InFile or $ nl -ba -s" " a | sort -nr | sed -E 's/^ *[0-9]+ //' or $ sed -n '1!G;h;$p' InFile or $ gawk '{ L[n++] = $0 } END { while(n--) print L[n] }' InFile ###Advanced Usage (beginners can skip) gtac -b -r -s file the options are esoteric bordering on the arcane -s separator -r separator is a regular expression -b place the separator before instead of after In Infile let us agree to regard the lines with arabic numerals as header lines. In this case, the separator is "^[0-9]+" $ gtac -b -r -s"^[0-9]+" InFile 2 C D 1 A B This ouptut is useful if you regard the lines with numerals as "headers" and the lines below them (until the next header) as records. Then we have a multi-line record. The second output reverses the multi-line records whereas the first output is a simple reversal of all lines. The best way to see the difference between the last two outputs is to place all three outputs side by side $ gtac InFile > Out1 $ gtac -b -r -s"^[0-9]+" InFile > Out2 $ paste InFile Out1 Out2 1 D 2 A C C B 2 D 2 B 1 C A A D 1 B OR $ paste Infile <(gtac InFile) <(gtac -b -r -s"^[0-9]+" InFile) #no intermediate files!! #pure bash MAGIC ------------------------------------------------------------------------ look ------------------------------------------------------------------------ look searches input sorted file and displays lines with a given string. you can use grep but look does a binary search and is very fast. If no filename is given then the internal dictionary file is used /usr/share/dict/words Most useful when you are looking for a word "starting with" but do not know the rest of the word. e.g. $ look embaras $ look embarr ------------------------------------------------------------------------ yes ------------------------------------------------------------------------ Useful when you need to give the same answer to questions asked repetitively. For instance, let us say that you wish to delete a large number of files which have permissions such that you need to reply "y" or "yes" for each file $ yes | rm *.txt Other uses of yes are to generate files to test systems $ yes "Hello Kitty" | sed '10q' > Kitty.txt #will generate a file Kitty.txt with 10 identical lines #equivalently $ yes "Hello Rusty" | head -10 > Rusty.txt ------------------------------------------------------------------------ cowsay ------------------------------------------------------------------------ $ cowsay hello ------------------------------------------------------------------------ sl ------------------------------------------------------------------------ $ sl ------------------------------------------------------------------------ figlet ------------------------------------------------------------------------ $ figlet hello kitty