shell - need to search lines containing specific string pattern -
i checking if current line read awk contains strings using:
if (/.*abc.*lab.*/) { } but if string in line e.g.
[abc ls:lab=123 ....].. then string searched correctly, if line contains e.g.
[abc ls:key=xyz xyz. ls:lab=123 ...].. then line not searched though matches .*abc.*lab.*
can please correct me if doing mistake while searching?
you should able use:
awk '/abc.*lab/ { print $0 }' the pattern matched against $0, whole line. however, wrote should work if written as:
awk '{if (/.*abc.*lab.*/) print $0}' or simpler regex:
awk '{if (/abc.*lab/) print $0}' if don't have if inside { ... }, you've got syntactic problems awk.
given data file this:
[abc ls:lab=123 ....].. string searched correctly, if line contains e.g. [abc ls:key=xyz xyz. ls:lab=123 ...].. the scripts above produce:
[abc ls:lab=123 ....].. [abc ls:key=xyz xyz. ls:lab=123 ...]..
Comments
Post a Comment