Deleting the first two lines of a file using BASH or awk or sed or whatever

后端 未结 4 1594
独厮守ぢ
独厮守ぢ 2021-01-31 15:48

I\'m trying to delete the first two lines of a file by just not printing it to another file. I\'m not looking for something fancy. Here\'s my (failed) attempt at awk:



        
4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-31 16:28

    awk is based on pattern{action} statements. In your case, the pattern is NR>2 and the action you want to perform is print. This action is also the default action of awk.

    So even though

    awk 'NR>2{print}' filename

    would work fine, you can shorten it to

    awk 'NR>2' filename.

提交回复
热议问题