homepage Welcome to WebmasterWorld Guest from 174.129.76.87
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
remove lines in multiple files
SED, Perl, Delete lines, multiple files
travlang

10+ Year Member



 
Msg#: 3933209 posted 11:22 pm on Jun 14, 2009 (gmt 0)

I need to remove line numbers 6 to 106 on over 100000 html files. I tried sed

sed '6,106d' *.html
but this outputs to the screen
sed '6,106d' x.html > x.bak
works but I cannot do one file at a time. Does anyone know of a way to use wildcards in the output file or of a script that will go through every file in a directory and remove those numbered lines
Thanks
Howard

 

bkeep

5+ Year Member



 
Msg#: 3933209 posted 4:17 pm on Jun 27, 2009 (gmt 0)

Have you tried using find?

find . -type f -name "*.html" -exec sed '6,106d' {} > {}.bak \;

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 3933209 posted 12:00 pm on Jul 26, 2009 (gmt 0)

or use a for loop:
for i in *.html; do
sed '6,106d' $i > $i.bak
done

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved