cli-sedHow do I delete a line using the CLI sed command?
The sed command can be used to delete a line from a text file. The syntax to delete a line using sed is sed 'Nd'
. Here, N is the line number of the line to be deleted. For example, to delete the third line from a text file, the command would be:
$ sed '3d' file.txt
The output of the above command would be the contents of the text file, with the third line deleted.
The parts of the command are:
sed
: the sed command'3d'
: the argument to the sed command, which specifies the line number to deletefile.txt
: the name of the text file to be edited
For more information about using the sed command to delete lines, see the following links:
More of Cli Sed
- How do I use the commandline sed tool to edit a file?
- How can I use the command line to compress and edit files with sed and zip?
- How can I use SED in a Windows command line interface?
- How can I use sed in a command line interface?
- How can I use a variable with the sed command line tool?
- How can I set up the Xcode command line interface?
- How can I use the command line tool sed to create a tutorial?
- How can I use sed in the command line on macOS?
- How do I use the CLI to configure Zabbix?
- How can I use CLI sed and Yarn together to develop software?
See more codes...