Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
Due to network maintenance being performed by our provider, LQ will be down starting at 05:01 AM UTC. The exact duration of the downtime isn't currently known. We apologize for the inconvenience.
|
 |
11-05-2004, 06:27 PM
|
#1
|
|
Member
Registered: Sep 2004
Location: NH
Distribution: FC6, FC1-4, RH9, Gentoo 2006.0/1, Slackware 10.1/2,11, Vector SOHO 5.0.1
Posts: 237
Rep:
|
Deleting a line with gawk/awk
I was wondering how I would delete a line using gawk/awk.
have this command to find the line I want to delete:
Code:
gawk '/\/dev\/sda1/ { print }' test1
I know I shouldn't be printing the line, but is ther something I can put in the braces to remove the line from the text file. I am trying to use this in a script that a non-linux user can use to finalize installaions for me while I move on to the next machine.
Thanks in advance.
|
|
|
|
11-05-2004, 07:21 PM
|
#2
|
|
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 3,816
Rep: 
|
Why do you need to use gawk? I just do a grep -v on the regular expression and redirect the ouput wherever you want it to go.
|
|
|
|
11-05-2004, 07:30 PM
|
#3
|
|
Member
Registered: Sep 2004
Location: NH
Distribution: FC6, FC1-4, RH9, Gentoo 2006.0/1, Slackware 10.1/2,11, Vector SOHO 5.0.1
Posts: 237
Original Poster
Rep:
|
Oh, wow that is much easier. Thanks.
(Oh if anyone saw the post that was here for about 1 minute, taht was because I didn't read the right "-v"  )
Last edited by caps_phisto; 11-05-2004 at 07:33 PM.
|
|
|
|
11-06-2004, 01:13 PM
|
#4
|
|
Member
Registered: Aug 2004
Distribution: debian, SuSE
Posts: 365
Rep:
|
sed would work too
sed '/searchpattern/d' filename >newfile
|
|
|
|
11-06-2004, 02:31 PM
|
#5
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
And just so awk doesn't fall aside ...
awk '!/hda1/ {print}' /etc/fstab
awk is absolutely awksome! :)
Cheers,
Tink
|
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:28 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
|
|