嘿,我有一个看起来像这样的CSV文件:
ID,Page_Number,Subject,Description,Upvotes
1,3,Fruit", An apple", 5
2,3,"School","The yellow Banana",8
3,4,"Restaurant","The red apple",4
4,5,"School","The big apple",5
5,5,"Apple","Great for a snack",5
因此,我想搜索包含单词apple的所有行,无论它是否在主题或描述列中并返回所有行都无所谓。我应该使用AWK命令吗?
结果应该是:
ID,Page_Number,Subject,Description,Upvotes
1,3,Fruit", An apple", 5
3,4,"Restaurant","The red apple",4
4,5,"School","The big apple",5
5,5,"Apple","Great for a snack",5
有很多方法。试试这个
grep -i 'apple' file
sed '/\<apple\>/I! d' file
awk '{IGNORECASE=1}/apple/{print}' file
希望这会有所帮助。
awk 'BEGIN{IGNORECASE=1}; NR==1 {print}; /[Aa]pple/ {print}' filename