Tuesday, August 31, 2010

PC Scripts Daily - 08/31/2010

Welcome to the fourth edition of PC Scripts Daily! Again, I didn't post yesterday. For today, I have part three of the Bash tutorial.


Bash Tutorial - Part 3: File I/O

You know how to get input from and output information to the terminal. Now, I'm going to teach you how to do the same with files. This is useful for file processors like sed.

To output information to a file, you use the echo command with the output redirector, >. For example, if you want to echo "Hello World" to a file called foo.txt in the present working directory, you would type echo "Hello World" > foo.txt.

To send the contents of a file as arguments of a command, you would type <command> 'cat <file name>'. When you put a command between backticks, Bash will execute the command and replace it with the output.


Next Edition

Tomorrow, I might post later than 3:00 because I need time to write about the Apple event. I will also have part four of the Bash tutorial.

No comments:

Post a Comment