Hi there
my file looks like this
1 a b c d e f
2 a b b c d e f f g h e t t
3 a c b d e f
4 a b c
i want to print the line which has the fields containing ONLY a b c, in this case the line 4.
How can i awk it !!!?
Many Thanks in advance!
Hi there
my file looks like this
1 a b c d e f
2 a b b c d e f f g h e t t
3 a c b d e f
4 a b c
i want to print the line which has the fields containing ONLY a b c, in this case the line 4.
How can i awk it !!!?
Many Thanks in advance!
Assuming your 1 2 3 4 are not part of the file
awk '$0=="a b c" ' file
Thanks but it doesnt help...may be am wrong in the question.
I reframe the question:
John a b c d e f
Bob a b c
Fred b c a
Tom a c d f e
i want to print the lines Bob and Fred which contain the "a b c"
awk '/a b c/' file
Regards
nawk -f saint.awk myFile
saint.awk:
BEGIN {
str="a b c"
n=split(str, strA, FS)
for(i=1; i<=n; i++) {
strA[strA]
delete strA
}
}
{
for(i=2; i<=NF; i++)
if (!($i in strA)) next
print
}
YMMV depending on what you mean by 'a b c'.
It works but it prints only the line containing a b c in the given order and not if the line contains a b c in different order
awk '/Bob/ || /Fred/ && /a/ && /b/ && /c/' file
# awk '/[a-c] [a-c] [a-c]$/' file
Bob a b c
Fred b c a
Fred x c b a