s*****i 发帖数: 650 | 1 source file input.txt:
386 2048 D403 MG0011 100
486 4096 D404 MG0012 270
386 8192 A423 CC0177 400
486 8192 A424 CC0182 670
286 4096 A423 CC0183 100
286 4096 A425 CC0184 80
68020 2048 B406 EE1029 80
68030 2048 B410 EE1030 100
"trs80" 64 Z101 EL0020 0
If I use the following command:
$> awk '$1 ~ /[^23468]/ {print $0}' input.txt
The output is:
XT 640 D402 MG0010 0
Mac 4096 B407 EE1027 80
Apple 4096 B406 EE1028 40
68020 2048 B406 EE1029 80
68030 2048 B410 EE1030 100
$unix | a******g 发帖数: 88 | 2 ?? when I run your command I got
>awk '$1 ~ /[^23468]/ {print $0}' input.txt
68020 2048 B406 EE1029 80
68030 2048 B410 EE1030 100
"trs80" 64 Z101 EL0020 0
【在 s*****i 的大作中提到】 : source file input.txt: : 386 2048 D403 MG0011 100 : 486 4096 D404 MG0012 270 : 386 8192 A423 CC0177 400 : 486 8192 A424 CC0182 670 : 286 4096 A423 CC0183 100 : 286 4096 A425 CC0184 80 : 68020 2048 B406 EE1029 80 : 68030 2048 B410 EE1030 100 : "trs80" 64 Z101 EL0020 0
| s*****i 发帖数: 650 | 3 I am sorry for there is sth wrong with the pasting.
the input file should be like below:
XT 640 D402 MG0010 0
386 2048 D403 MG0011 100
486 4096 D404 MG0012 270
386 8192 A423 CC0177 400
486 8192 A424 CC0182 670
286 4096 A423 CC0183 100
286 4096 A425 CC0184
【在 a******g 的大作中提到】 : ?? when I run your command I got : >awk '$1 ~ /[^23468]/ {print $0}' input.txt : 68020 2048 B406 EE1029 80 : 68030 2048 B410 EE1030 100 : "trs80" 64 Z101 EL0020 0
| a******g 发帖数: 88 | 4 Your original regex means that there is a match when anything other than
2,3,4,6, or 8 appears in $1. What you what to say, is that if anything
like 2,3,4,6,or 8 appears, it does not match.
Use this
awk '$1 !~ /[23468]/' input.txt
notice the ! before ~, and the removal of ^
【在 s*****i 的大作中提到】 : I am sorry for there is sth wrong with the pasting. : the input file should be like below: : XT 640 D402 MG0010 0 : 386 2048 D403 MG0011 100 : 486 4096 D404 MG0012 270 : 386 8192 A423 CC0177 400 : 486 8192 A424 CC0182 670 : 286 4096 A423 CC0183 100 : 286 4096 A425 CC0184
| s**a 发帖数: 79 | 5 Isn't that just
awk '/^[^23468]/' input.txt?
cheers,
sd
【在 a******g 的大作中提到】 : Your original regex means that there is a match when anything other than : 2,3,4,6, or 8 appears in $1. What you what to say, is that if anything : like 2,3,4,6,or 8 appears, it does not match. : Use this : awk '$1 !~ /[23468]/' input.txt : notice the ! before ~, and the removal of ^
|
|