New User? Register here - Existing Users: Username: Password: [Advanced Login]

 

 

Current Poll

Your preferred Interactive shell?









( 1355 votes ~ 14 comments )

 

Weblog entry #18 for lee

Removing extra lines with sed
Posted by lee on Mon 8 May 2006 at 14:29
Tags: none.

I just needed to download a lot of streaming video files from the management interface of a third party streaming service. However they didn't seem to play properly when downloaded.

Comparing a downloaded file with a copy of the file that was uploaded showed that the download stream seems to have inserted a blank line at the beginning of the file and several blank lines at the end. A quick web search gave me the following sed tricks for removing them:

 mkdir filtered
 for i in `ls *.rm`; do sed "1d" $i | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' > filtered/$i ; done

 

Comments on this Entry

Posted by Anonymous (83.105.xx.xx) on Mon 22 May 2006 at 14:35
for i in *.rm

would suffice ;)

[ Parent | Reply to this comment ]

 

 

Flattr