Hi Folks:
I am trying to print a line if the pattern is not on that line.
I am writing all the statements in a script file.
I can make it work from the command line, but it did not work when i try to do the same from the script file.
For example, my input file is:
Hello World
Hello USA[1]
Hello USA[2] USA[3]
I only need to print when a line does not contain USA.
The following line works from command line:
awk '$2 !~/USA/ && $3 !~/USA/ {print $0}' <input file>
But when i put the same in the script file, it does not give the desired results. I have even tried to use the if condition, but the result stays the same.
In summary, I want to print a line if it does not contain a certain pattern.
Thanks,
Indiana
I am trying to print a line if the pattern is not on that line.
I am writing all the statements in a script file.
I can make it work from the command line, but it did not work when i try to do the same from the script file.
For example, my input file is:
Hello World
Hello USA[1]
Hello USA[2] USA[3]
I only need to print when a line does not contain USA.
The following line works from command line:
awk '$2 !~/USA/ && $3 !~/USA/ {print $0}' <input file>
But when i put the same in the script file, it does not give the desired results. I have even tried to use the if condition, but the result stays the same.
In summary, I want to print a line if it does not contain a certain pattern.
Thanks,
Indiana