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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-08-2009, 04:23 AM
|
#1
|
LQ Newbie
Registered: Dec 2009
Posts: 1
Rep:
|
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
|
|
|
12-08-2009, 05:26 AM
|
#2
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
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.
|
|
|
12-08-2009, 06:41 AM
|
#3
|
Member
Registered: Jan 2009
Location: 127.0.0.1
Distribution: Fedora, CentOS, NetBSD
Posts: 115
Rep:
|
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.
|
|
|
12-08-2009, 08:17 AM
|
#4
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
sed "$num,+1d" filename
(deletes 2 lines, starting with $num)
|
|
|
All times are GMT -5. The time now is 09:06 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|