-   Linux - General (
-   -   Deleting a line with gawk/awk (

caps_phisto 11-05-2004 06:27 PM

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:

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.

btmiller 11-05-2004 07:21 PM

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.

caps_phisto 11-05-2004 07:30 PM

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" :) )

amfoster 11-06-2004 01:13 PM

sed would work too

sed '/searchpattern/d' filename >newfile

Tinkster 11-06-2004 02:31 PM

And just so awk doesn't fall aside ...

awk '!/hda1/ {print}' /etc/fstab

awk is absolutely awksome! :)


All times are GMT -5. The time now is 06:29 AM.