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

后端 未结 4 1566
独厮守ぢ
独厮守ぢ 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:25

    You're nearly there. Try this instead:

    awk 'NR > 2 { print }' myfile
    

    awk is rule based, and the rule appears bare (i.e., without braces) before the block it woud execute if it passes.

    Also as Jaypal has pointed out, in awk if all you want to do is print the line that matches the rules you can even omit the action, thus simplifying the command to:

    awk 'NR > 2' myfile
    

提交回复
热议问题