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 can I use SED in a Windows command line interface?
- How can I use sed in a command line interface?
- How can I set up the Xcode command line interface?
- How do I use CLI sed to uninstall a module?
- How can I use CLI sed to edit a file?
- How can I use the command line to compress and edit files with sed and zip?
- How do I use the command line to compress a file using SED and ZIP?
- How can I use a variable with the sed command line tool?
- replace text
- How can I use sed to manipulate a JSON file from the command line?
See more codes...