February 28th, 2011, 04:20 PM
Is there a "revese" flag in unix tail command?
iv'e been given a homework assignment in which i should
among other things print a part of a text file backwards from the end using the unix command TAIL with some reverse flag
i searched in the man page and did not find such flag,
then googled it and found the following :
tail [+ number] [-l] [-b] [-c] [-r] [-f] [-c number | -n number] [file]
where -r is the reverse flag
but when i run "tail -r myfile.txt"
in the termial i get "tail: invalid option -- 'r' "
so is it becouse my unix is too old or somthing?
or what is going on with that ?
and im using xubuntu 10.10 on virtual machine if it matters
February 28th, 2011, 04:47 PM
You can pipe the output of 'tail' to the 'rev' utility.
March 1st, 2011, 01:51 AM
thanks for the reply but the rev utility reverse the order of characters in every line, i need to reverse the order of the lines
Originally Posted by ishnid
something like: "tail -r -2 myfile.txt"
that will print to terminal:
"last line of file..."
"second to last line of file..."
March 1st, 2011, 05:32 AM
Sorry, I misread the manpage - try "tac" instead.