cli-sedHow do I use the commandline sed tool to edit a file?
sed (stream editor) command line tool can be used to edit a file. This is done by using the
-i flag when running
sed and providing an expression to apply to the file.
For example, to replace the word
goodbye in a file named
example.txt, the following command can be used:
sed -i 's/hello/goodbye/g' example.txt
This command will replace all occurrences of
goodbye in the
The parts of the command are:
sed: The command to run the stream editor.
-i: The flag to indicate that the changes should be applied to the file directly.
s/hello/goodbye/g: The expression that will be applied to the file. This expression is a substitute command, which will replace all occurrences of
example.txt: The name of the file to apply the expression to.
For more information about
sed, see the following links:
More of Cli Sed
- How can I use the 'sed' command line utility to add quotes around a string?
- How do I use the CLI to configure Zabbix?
- How can I use the command line to compress and edit files with sed and zip?
- How can I use the command line to edit text using Qt?
- How can I use SED in a Windows command line interface?
- How can I set up the Xcode command line interface?
- How do I use sed to add quotes around a string in a command line interface?
- How do I use the command line to compress a file using SED and ZIP?
- How can I use sed in a command line interface?
- How do I use the command line to edit text using sed?
See more codes...