#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    17
    Rep Power
    0

    Is there a "revese" flag in unix tail command?


    hello all,
    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 ?

    thanks,

    and im using xubuntu 10.10 on virtual machine if it matters
  2. #2
  3. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,897
    Rep Power
    3886
    You can pipe the output of 'tail' to the 'rev' utility.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    17
    Rep Power
    0
    Originally Posted by ishnid
    You can pipe the output of 'tail' to the 'rev' utility.
    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

    something like: "tail -r -2 myfile.txt"

    that will print to terminal:

    "last line of file..."
    "second to last line of file..."
  6. #4
  7. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,897
    Rep Power
    3886
    Sorry, I misread the manpage - try "tac" instead.

IMN logo majestic logo threadwatch logo seochat tools logo