How Do You Remove the First N Line in Unix?
Contents How Do I Remove the First Line in Unix? Using the Sed Command Removing the First Line from an Input File Using the Sed Command Is Pretty...
Contents
How do I remove the first line in Unix?
Using the sed Command
Removing the first line from an input file using the sed command is pretty straightforward. The sed command in the example above isn’t hard to understand. The parameter ‘1d’ tells the sed command to apply the ‘d’ (delete) action on line number ‘1’.
Must Read
How do I remove the first N line from a file?
How it works :
- -i option edit the file itself. You could also remove that option and redirect the output to a new file or another command if you want.
- 1d deletes the first line ( 1 to only act on the first line, d to delete it)
- $d deletes the last line ( $ to only act on the last line, d to delete it)