Bash - remove all lines beginning with 'P'

前端 未结 5 837
Happy的楠姐
Happy的楠姐 2020-12-09 12:43

I have a text file that\'s about 300KB in size. I want to remove all lines from this file that begin with the letter \"P\". This is what I\'ve been using:

&g         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 13:17

    Use sed with inplace substitution (for GNU sed, will also for your cygwin)

    sed -i '/^P/d' file.txt
    

    BSD (Mac) sed

    sed -i '' '/^P/d' file.txt
    

提交回复
热议问题