PDA

View Full Version : [ubuntu] Commandline tail -r



Surfer-07
December 5th, 2009, 03:27 PM
Hello everybody,

I'm having a problem using the command line.

For some script I need the "tail -r" command but in the new version of the command the -r option isn't available anymore.

Is it possible to downgrade the tail command or is there any alternative?

Grtz ;)

(I'm using Ubuntu 9.10 64bit)

phillw
December 5th, 2009, 04:34 PM
Hi,

what did the -r option used to do ?

Phill.

lswb
December 5th, 2009, 05:36 PM
I see that the version of tail on BSD systems includes the -r option. Looks like the GNU version does not.

Something like this will have the same effect:


tail filename|cat -n|sort -nr|cut -f2

Surfer-07
December 5th, 2009, 06:00 PM
Hi,

what did the -r option used to do ?

Phill.

Option '-r' stands for reverse. It puts the file content upside down.

For example:

bash~$ cat Test.txt
Line1
Line2

bash~$ tail -r Test.txt
Line2
Line1


I see that the version of tail on BSD systems includes the -r option. Looks like the GNU version does not.

Something like this will have the same effect:


tail filename|cat -n|sort -nr|cut -f2


That also works. You can even make it shorter:
cat -n filename | sort -nr | cut -f2 ;)
But is there no other alternative?

Grtz

Surfer-07
December 5th, 2009, 06:30 PM
I just found the solution.
There is a "tac" command that works great :)
just use bash:$ tac Test.txt