4
Redirecting Output to a File Examples This command generates output and errors when run as non- root: $ ls –l f1.txt > f2.txt (only result is stored not error) Operators can be used to store output and errors: $ ls –l tot.txt 2> f3.txt(only error is stored not the result) $ ls –l tot.txt f1.txt &> f3.txt (concatenates the result and stores in f3.txt)

5
Redirecting STDOUT to a Program (Piping) Pipes (the | character) can connect commands: command1 | command2 Sends STDOUT of command1 to STDIN of command2 instead of the screen. STDERR is not forwarded across pipes Used to combine the functionality of multiple tools command1 | command2 | command3... etc

11
Scripting: for loops Performs actions on each member of a set of values Example: for NAME in joe jane julie do MESSAGE='Projects are due today!' echo $MESSAGE | mail -s Reminder $ADDRESS done Can also use command-output and file lists: for num in $(seq 1 10) Assigns 1-10 to $num seq X Y prints the numbers X through Y for file in *.txt Assigns names of text files to $file