Saturday, January 8, 2011

Text Processing 1

Let's just get down to it.

<>

> Redirects a command's output to a file

>> Does the same as above but appends it to the end of the file instead of overwriting

The book mentions there are multiple ways to do things such as

sort <>

The | I just used is a pipe. It allows you to chain two or more program's output.

tee performs like > but it sends the output to a file while also passing it to console so you can monitor what is occuring.

sort is a command that can sort a file's contents.

nl is a command that can number lines in a file which can make it easier to troubleshoot source code (if for some reason you're coding in vim...)

Apparently there is a witty command by the name of tac that can display a file backwards...

sed. For some reason the book refuses to give a good explanation so here are examples of what it can do.

sed s/cat/tac/ file will replace the first instance of cat with tac. Add "g" after /tact/ and it will replace every instance of cat with tac. Me and Henry actually used this when editing the /etc/hosts hostsname files since it contained the hostname more than once.

grep in most simple terms can find a string or phrase and return it to you.

Next is chapter 9 the Software Installation chapter and then I'm done LPIC part one...

1 comment:

  1. Great stuff all this piping and redirecting. As much fun as it is useful!

    ReplyDelete