Q:

UNIX sed command help

    sed -n '$'!p abc.txt | tail +2 > def.txt

I have the above mentioned sed command in my code - I am unable to figure out what it does -I am going through sed tutorials to find it out but am not able to - Can some one please help me in figuring out what it does - Thanks

A:

Taking this in stages:
sed -n abc.txt    

"Run abc.txt through sed, but don't print anything out."
sed -n '$!p' abc.txt

(Note that I've corrected what I think was a misplaced quote mark.)
"Run abc.txt through sed; if a line isn't the last line, print it (i.e. print all but the last line)."
I guess you know the rest, but note that tail +2 is obsolete syntax-- tail -n 2 would be better.
EDIT:
To remove the last two lines, try
sed 'N;$d'

or if that doesn't work, crude but effective:
sed '$d' | sed '$d'

