Exercises: IO-Redirection, Pipes#
Use the
catprogram (without any commandline parameters) to copy/etc/passwdto/tmp/passwd.Use the
echocommand (call it multiple times in a row) to create a file that contains your name and your address.Output a sorted list of all users in your system. Hint:
/etc/passwdcontains all users in the first column - fields are separated with the:character.Redirect standard output and standard error of the command
find /etcto/tmp/output.txtWhy is the (non-empty) file
/tmp/outputsuddenly empty after running the commandcat < /tmp/output > /tmp/output?Run the commands
$ echo Howdy > /tmp/output $ cat < /tmp/output >> /tmp/output
What do you notice?
Explain!
How many subdirectories does your home directory contain? Hint: combine
findundwcin a pipeline.Modify the command
find /etc | wc, applying redirections, so that it counts the number of lines on standard error, and standard output is sent to/dev/null.Using
echo,cat, andmkfifo, send the word “Howdy” in circles such thatcatconsumes as much CPU time as it can get.