Interesting Commands in Linux
[ 1. shuf ]
The shuf command -- short for "shuffle" reorganizes the lines of a file in some pseudorandom way. Start out with a file listing the days of the week and you can rearrange them in any of 5,040 ways (7 * 6 * 5 * 4 * 3 * 2). Maybe more useful for determining who brings cookies into the office each day for the next couple of weeks.
$ shuf Days-of-Week
Monday
Tuesday
Wednesday
Saturday
Thursday
Sunday
Friday
$ shuf Days-of-Week
Sunday
Saturday
Wednesday
Tuesday
Thursday
Monday
Friday
[ 2. rev ]
The rev command reverses lines whether passed to the command as standard in or stored in a file.
$ rev Days-of-Week
yadnuS
yadnoM
yadseuT
yadsendeW
yadsruhT
yadirF
yadrutaS
[ 3. tac ]
The tac command is sort of the reverse of the cat command. It displays the content of a file, but in reverse order. There are probably many times when doing this can be both handy and sensible, but the command still strikes me as odd.
$ tac Days-of-Week
Saturday
Friday
Thursday
Wednesday
Tuesday
Monday
Sunday
[ 4. look ]
The look command can be handy if you need to come up with words that start with a particular string. In the example below, we're looking for words that start with the string "fun".
$ look fun | head -11
fun
funambulant
funambulate
funambulated
funambulating
funambulation
funambulator
funambulatory
funambule
funambulic
funambulism
[ 5. yes ]
The yes command puts you into a loop that repeats the same string over and over again. It does have some useful purposes, though, even while this behavior might seem silly. People sometimes use it to provide as many "yes" responses as might be need to handle a demanding script.
The default behavior of yes is to provide an endless loop of "y" responses.
$ yes | head -4
y
y
y
y
You can, however, supply your own string.
$ yes Please loop forever | head -11
Please loop forever
Please loop forever
Please loop forever
Please loop forever
Please loop forever
Please loop forever
Please loop forever
Please loop forever
Please loop forever
Please loop forever
Please loop forever
[ 6. cowsay ]
Probably one of the oddest commands that the powers behind Linux have come up with is the cowsay command that displays an ASCII cow saying whatever you want it to say. Here's an example. Note the use of the escape character to allow the display of the apostrophe.
$ cowsay I don\'t moo for just anyone
_____________________________
< I don't moo for just anyone >
-----------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
[ 7. factor ]
Another unusual, though not really silly, command is the factor command that factors whatever number you provide. I just happened to try a number that has just two factors.
$ factor 33431
33431: 101 331
[ 8. figlet ]
The last unusual command that I'm going to cover is called figlet. It uses a small number of enlarged keyboard characters to create banner text.
$ figlet Show me!
$ figlet Show me!
Comments
Post a Comment