Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

remove lines in multiple files

SED, Perl, Delete lines, multiple files

11:22 pm on Jun 14, 2009 (gmt 0)

New User

10+ Year Member

joined:Oct 30, 2004
posts: 4
votes: 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
4:17 pm on June 27, 2009 (gmt 0)

Full Member

10+ Year Member

joined:June 1, 2007
votes: 0

Have you tried using find?

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

12:00 pm on July 26, 2009 (gmt 0)


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

joined:Aug 10, 2004
votes: 236

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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members