輸入:
CC2352345|m,safnlasndfmnyxdcvyxcvyxcv |klasjdf |3|lasdjflasdf| |2345567356
CC3543353|asdfasdffghntz |klasjdf |3|lsajdfl | |3456561235
CC5634554|asfjmklasdfassasdasasdsdfas |klasjdf |3|lsajdfl | |2345635636
|masdfjklasdfjasldfjlasjdfklas| | | | |2345234566
CC4723456|asdjkfasjkldfjaklsjdflkajldkfjlasjdflk |klasjdf |2|lsajdfl | |2345234525
DD3455463|asldfklklfaem,.rtklqerktljekltjklqe |klasjdf |3|lsajdfl | |4565467546
輸出:
CC2352345|m,safnlasndfmnyxdcvyxcvyxcv |klasjdf |3|lasdjflasdf| |2345567356
CC3543353|asdfasdffghntz |klasjdf |3|lsajdfl | |3456561235
CC5634554|asfjmklasdfassasdasasdsdfas |klasjdf |3|lsajdfl | |2345635636
CC4723456|asdjkfasjkldfjaklsjdflkajldkfjlasjdflk |klasjdf |2|lsajdfl | |2345234525
DD3455463|asldfklklfaem,.rtklqerktljekltjklqe |klasjdf |3|lsajdfl | |4565467546
問題:如何刪除第一列為空的行?
答案1
用這個:
sed '/^\s\s*/d' file
甚至:
grep -v '^\s' file
答案2
怎麼樣awk
,因為沒有提到?
awk -F\| '$1~/\w/' file