Results 1 to 7 of 7
Hi,
I want to delete lines which contain the word "Fehler" but for some reason my programm isn't working:
Code:
BEGIN { FS="|"
OFS="|"
SUBSEP="|"
anzArg = 2
if (ARGC ...
- 10-13-2010 #1Just Joined!
- Join Date
- Oct 2010
- Posts
- 2
gawk - delete line in file
Hi,
I want to delete lines which contain the word "Fehler" but for some reason my programm isn't working:
My input file looks like this:Code:BEGIN { FS="|" OFS="|" SUBSEP="|" anzArg = 2 if (ARGC < anzArg) { print "Zuwenig Argumente" print "gawk -f makeEGNinput.awk inputfiles" nosource = "true" exit 1 } } { # Main if (FNR == 1) { outfile = (FILENAME ".load") print ("Outfile: " outfile) } # Delete path split($5,arrDatei,"/") # Delete line with <Fehler> if ($5 != "<Fehler>"){ n = asort(arrDatei,arrCount) $5 = arrDatei[n] } #print $0 print $0 > outfile }
00036425|06|2010|0001|/usr/swas/pmscp/betr/eis/teis/EGN_00036425_20101013091045.pdf
00041332|06|2010|0000|<FEHLER>
00036425|06|2010|0001|/usr/swas/pmscp/betr/eis/teis/EGN_00036425_20101013091045.pdf
I can somebody help me?
Thanx
frog_123
- 10-13-2010 #2
Does it need to be gawk?
grep -v FEHLER inputfile
should fullfill your requirements.You must always face the curtain with a bow.
- 10-13-2010 #3Just Joined!
- Join Date
- Oct 2010
- Posts
- 2
thanks a lot for that simple solution!!
- 10-14-2010 #4Just Joined!
- Join Date
- Jul 2008
- Posts
- 81
In any case, you were testing for "Fehler" while expecting "FEHLER".
- 10-14-2010 #5Just Joined!
- Join Date
- Jan 2008
- Posts
- 5
Or how about sed?
sed /FEHLER/d inputfile > outputfile
or if you want to change the inputfile directly:
sed -i /FEHLER/d inputfile
- 10-14-2010 #6Just Joined!
- Join Date
- Jan 2008
- Posts
- 5
And to correct myself, I see your inputfile contains slashes. Just use any delimiter not in your inputfile, for example:
sed #FEHLER#d inputfile > outputfile
Knut
- 10-14-2010 #7Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
And to correct your correction, sed doesn't really care about slashes in its input stream, it's already parsed them out of the pattern. It does, of course, care about slashes in the pattern argument.


Reply With Quote