Hidden Linux: cat, less, tac and shuf

cat (short for 'catalogue') is the traditional command for displaying a file on the Linux console. If the file's large and races away from you, less will keep it in check, displaying the contents page by page and allowing you to scroll forward and back with the arrow keys or PgUp and PgDn. (Hit 'q' to quit.)
But what if you want to display the file backwards?
What ...?
Log files' latest additons -- the ones you're most likely to be interested in -- are added to the end, so tac (that's 'cat' backwards) will take you there. In actual fact tac will most likely run away with you like cat so you'll need to pipe it through more:
| tac filename | more |
How about displaying a file's contents at random? shuf does just that. It's not particularly useful for log files, I grant you, or any other type of file for that matter. But remember, Linux commands work with any standard input so
| ls directoryname | shuf |
will list the contents of directoryname in random order.
Now imagine directoryname contains a batch of music files. The command
| ls | shuf | mplayer -playlist - |
will play them at random!
![]() |
![]() |



PC World is New Zealand’s top selling computing and technology magazine.
Comments
Hi. I like your column in PC World. Have you seen this? sent to me by my favourite paranoid. I havn't confirmed the accuracy though.
Army of Fake Social Media Friends to Promote Propaganda
Does a code of ethics still exist in Intelligence firms? Does it disappear behind closed doors, dirty deeds done in the dark and used against the American people who are supposed to be free to express themselves?D
Feb 24, 2011 11:03 am
It's recently been revealed that the U.S. government contracted HBGary Federal for the development of software which could create multiple fake social media profiles to manipulate and sway public opinion on controversial issues by promoting propaganda. It could also be used as surveillance to find public opinions with points of view the powers-that-be didn't like. It could then potentially have their "fake" people run smear campaigns against those "real" people. As disturbing as this is, it's not really new for U.S. intelligence or private intelligence firms to do the dirty work behind closed doors.
EFF previously warned that Big Brother wants to be your friend for social media surveillance. While the FBI Intelligence Information Report Handbook (PDF) mentioned using "covert accounts" to access protected information, other government agencies endorsed using security exploits to access protected information.
It's not a big surprise that the U.S. military also wants to use social media to its benefit. Last year, Public Intelligence published the U.S. Air Force social media guide which gave 10 tips for social media such as, "The enemy is engaged in this battlespace and you must engage there as well." Number three was "DON'T LIE. Credibility is critical, without it, no one cares what you have to say...it's also punishable by the UCMJ to give a false statement." The Air Force used the chart below to show how social media influences public opinion.
Posted by: MikeP | February 25, 2011 1:26 PM
Therefore: does
ls | shuf | tac | mplayer -playlist -
play the music backwards??
:-)
Posted by: Adrian | February 21, 2011 1:00 PM