in reply to Re: Command line file sorting
in thread Command line file sorting


Thanks. I was playing with sort earlier, and was unable to make this work properly. Your solution still has one problem that I need to address, something that I didn't mention above. If there is only one entry, the entry sometimes* gets printed, but I need that result to be empty. Is there an easy way to do this from the shell?

* - I say sometimes, because on bash under linux, it does not get printed due to an extra blank line that somehow gets generated in the output. On AIX and MacOS X, the entry gets printed.

Replies are listed 'Best First'.
Re^3: Command line file sorting
by artist (Parson) on Sep 05, 2007 at 19:15 UTC
    Following should not print anything, if there is no data in the 2nd line.
    cat data | awk NR==2