LINUX: Send the last 3 lines of the output of the who command to a file called out1?
I recently learned about Filters in my Linux class. However this is throwing me off. I know what the who command is and about the tail command but how do I send it to a out1? And where does who fit into this?
is it who tail +3 > out1 ? Any help is appreciated. |
Close
As written, you're passing "tail" and "+3" as arguments to "who". What you need instead is to run "who" by itself, and redirect its output to the input of "tail". In Linux there are two types of I/O redirection, ">" and ">>" redirects output to a file, which you have done correctly, while "|" redirects output to the input of another process. You need to stick a "|" between "who" and "tail" so that the "tail" program can process the output of "who", rather than passing the literal string "tail" as an argument to "who". |
Code:
tail -3 who >> out1 Did you notice? Code:
who Code:
who | tail -3 Code:
who >> out1 Never ever saw Code:
tail -3 who #whatever See http://www.tldp.org/LDP/abs/html/io-redirection.html |
All times are GMT -5. The time now is 08:23 AM. |