The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
remove : lines from file aronmelon Shell Programming and Scripting 5 06-10-2009 11:46 AM
remove lines from file lweegp Shell Programming and Scripting 10 03-15-2009 11:51 PM
vi to remove lines in file kjbaumann UNIX for Dummies Questions & Answers 2 03-13-2009 03:40 AM
To remove the lines in my file gsiva Shell Programming and Scripting 5 03-05-2009 06:13 AM
remove lines from file bluemoon1 Shell Programming and Scripting 9 11-09-2007 01:40 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-21-2009
Gussifinknottle Gussifinknottle is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 20
Question Remove n lines from every file in a directory

Hello,

I would like to remove n lines from all the files in a given directory. If it were one file, I can use the
sed 'start, finish d' command.

How can I extend this to an entire directory of files?

Thanks,
Gussi.
  #2 (permalink)  
Old 06-21-2009
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
  
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 6,661
A simple search of this site provides many answers.

The search keywords are pretty easy

sed+multiple+files+in+a+directory
  #3 (permalink)  
Old 06-21-2009
Gussifinknottle Gussifinknottle is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 20
Thanks Neo. I did do something like what was suggested in one of the posts and executed the following script:

Code:
#!/bin/sh

for x in *
do
sed '1,13d' $x > temp
cat temp > $x
rm temp
done

exit 0
I ran this on a test data, two of the 3 files had the appropriate lines deleted. However, in the third one all of the lines were deleted. So I am not sure where I went wrong .

Thanks,
Gussi
Reply

Bookmarks

Tags
remove lines

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0