Berkeley CSUA MOTD:Entry 32593
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/07/09 [General] UID:1000 Activity:popular
7/9     

2004/7/30 [Computer/SW/Unix] UID:32593 Activity:high
7/30    Ack!  Too much politics!  I have a technical question:
        I have some files described by *.out and I want a nice scripty way to
        trim the last line off of each of them.  What's a good way to do this?
        \_ sed. $d
           \_ It would seem I'd need a pattern defining the last line for that
              to be helpful.
              \_ Erm.  try it out.  "sed '$d' filename"
                 \_ Thanks.
        \_ foreach i ( `ls` )
                mv $i `echo $i | sed s:.out::g`
           end
           Warning, this only works in csh.
           \_ in that case, just do foreach i (*.out).