Hi,
I need a awk command to identify a few pattern in a file and delete them.
Rule - Delete lines that has single/multi space within double quotes
Thanks.
Hi,
I need a awk command to identify a few pattern in a file and delete them.
Rule - Delete lines that has single/multi space within double quotes
Thanks.
How about...
awk '$1 ~ /^"/ && $1 !~ /"$/ {next} 1' myfile
---------- Post updated at 03:53 PM ---------- Previous update was at 03:49 PM ----------
If you have any lines with a double quote as the 1st character and a space as the 2nd character, then you'll need to amend as follows:
awk '$1 ~ /^"/ && (length($1)==1 || $1 !~ /"$/) {next} 1' myfile
This works fine, but may i know what this condition does.
$1 !~ /"$/
Yields true if the first field does not contain a double quote as the last character.