LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-08-2009, 03:23 AM   #1
Thom_de_Rijk
LQ Newbie
 
Registered: Dec 2009
Posts: 1

Rep: Reputation: 0
How to delete certain lines from lots of files in the same directory?


Hello everyone,

I want to delete 2 lines from each file in a certain directory (and all subdirectories). I was wondering if there is a simple command to accomplish this.
Thanks for any help,
Thom
 
Old 12-08-2009, 04:26 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
what have you tried? hint: use find to find your files. as for deleting lines, there are variety of tools you can use, eg awk, sed , or even the shell.
 
Old 12-08-2009, 05:41 AM   #3
action_owl
Member
 
Registered: Jan 2009
Location: 127.0.0.1
Distribution: Fedora, CentOS, NetBSD
Posts: 115

Rep: Reputation: 17
I recommend that you use a shell script with sed,

Give us some more information about what you're trying to accomplish and I'll help you out with the script.

Are you trying to delete lines at particular Line numbers? Do these lines have the same text in all files? please be specific.
 
Old 12-08-2009, 07:17 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
sed "$num,+1d" filename
(deletes 2 lines, starting with $num)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete lines and insert another line in some xml files using a shell script? luananeko Linux - Newbie 1 07-20-2009 09:53 PM
Unable to delete the lines in xml FILES ragavendran31 Linux - Newbie 1 01-19-2008 01:24 PM
delete lines from files bharatbsharma Programming 5 10-25-2007 08:43 AM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 09:19 AM
md5sum on a directory with lots of files. solarmax Linux - Software 5 08-11-2005 05:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration