Details

This week are are using the command in Linux called CAT to view Standard Input files.

Download HD Download MP4

Last time on HakTip, I promised cats. And I give you cats. We're actually redirecting standard inputs with a command called 'cat'. This stands for Concatenate Files- it reads one or more files and copies them to standard output.

It's kind of like 'type' in DOS. So if I typed cat ls-output.txt, this will list the contents of that text file to me. Usually cat's used to display small text files, but you can also use it to join a large file back together (sometimes larger files will be split this way). If I had three files named hak5.mpeg.001 hak5.mpeg.003 hak5.mpeg.009, I can rejoin them like this: cat hak5.mpeg.0* > hak5.mpeg. The wildcard asterisk will take all the hak5.mpeg.0* files and adjoin them from 1-9.

So standard inputs, right. Type cat and it does nothing because it's waiting for us to 'input' something into it. Now type 'trust your technolust' and hit CTRL-D, which tells cat the command is done. It'll retype trust your technolust as output. We can use this to make a text file like this: cat > trust.txt then hit enter and type trust your technolust. Hit CTRL-D again to end it. Now type cat trust.txt and it'll output your text file!

If you want to redirect standard input do this: cat < trust.txt. The less than sign redirects the source of input from the keyboard to the txt file. Not really useful until we get more in depth with redirecting inputs later on.

Next week, pipelines! Like in Mario! But first make sure to email me tips@hak5.org with your thoughts. And be sure to check out our sister show, Hak5 for more great stuff just like this. I'll be there, reminding you to trust your technolust.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

5 Comments