Keep or Remove The First Line From a File

  • Html
If you need to easily remove or keep the line at the beginning of the file you should use awk , it`s a powerful tool that can remove or keep any number of line from the beginning of the file.
1
Here is an example to show you how to remove the line 1 to 4 of a file.
cat file | awk ' NR>4'
2
Here is an example to show you how to keep the line 1 to 4 of a file.
cat file | awk ' NR<=4'

Please feel free to leave comments, suggestion or to share this post!

Click here to add a comment

Leave a comment: