Acting Catty

Acting Catty

We’ve spent some time over the past month talking about the ways to view and search files in Linux. As you’ve probably already noticed, The GnomeTWEAK section is full of these command line goodies. Today’s GnomeTWEAK is no exception. It’s a simple utility called cat and it serves much the same purpose as type in DOS.

cat, quite simply, allows you to view the contents of files. The name is Linux shorthand for concatenate. You can use cat to view the contents of a single file or many. Here’s how the command works:

    cat ~/mp3.list

will display the contents of mp3 list in my /home directory [~/]. I’ve created this file with redirection – using

     ls ./*.mp3 > ~/mp3.list

to list all my current mp3s and write the list to a file called mp3.list. But that’s not quite enough. You can string together several files into a single command:

     cat ~/mp3.list ~/mp3_wish.list

This series of commands will display the contents of both my current mp3 list and the ones I’d like to have. Even better, you can combine these lists into one by redirecting the output of the cat command to another text file:

    cat ~/mp3.list ~/mp3_wish.list > ~/all_mp3.list

The right arrow in this command sends the standard output from the cat command to a text file, written on the fly, called all_mp3.list.

This is a great example of the power to list, view and write files in Linux with, well, a cat.

Article Written by