Pls help with this clue:
a goal is to find a pattern and then ...
a) if it is found: {print $0}
b) if not: {print "NOT EXIST"}
Pls help with this clue:
a goal is to find a pattern and then ...
a) if it is found: {print $0}
b) if not: {print "NOT EXIST"}
Use the man pages:
man grep
Sorry. I was not precize. I want to include this search into awk program.
I know how to do the search and how to use if statement into awk. But I cannot manage to join those two. Maybe silly, but ...
With AWK
awk '{ if ( $0 ~ /PATTERN/ ) print $0 ; else print "NOT FOUND" } ' file.txt
With SED
sed -n -e '/PATTERN/!s/.*/NOT FOUND/gp' -e '/PATTERN/p' file.txt
awk '{print /pattern/?$0:"NOT EXIST"}' infile