Don't print lines where field#1 starts with contents of field#4

Don't print lines where field#1 starts with contents of field#4



Trying to exclude lines where field#1 starts with contents of field#4. Otherwise print line.



INPUT


f1|f2|f3|f4
Cheese Board|xx|xxx|Cheese
French Cheese|yy|yyy|Cheese



OUTPUT NEEDED


f1|f2|f3|f4
French Cheese|yy|yyy|Cheese



CODE TRIED (not working with carat^)


awk ‘ BEGIN "
if ( $1 !~ ^$4 ) print $0
‘ file




2 Answers
2


$ awk -F'|' 'index($1,$4)!=1' file
f1|f2|f3|f4
French Cheese|yy|yyy|Cheese



Could you please try following.


awk -F'[ |]' 'FNR==1print;next $1!=$NF' Input_file



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Malaysia to Papua New Guinea by motorcycle?

List of Bhojpuri films

PHP code is not being executed, instead code shows on the page