cli-sedHow can I use the command line to print the output of a sed command?
You can use the command line to print the output of a sed command by using the -n
flag. This flag suppresses the default output of sed, and instead prints only the output specified in the command.
For example, the following command prints the lines containing the word "example" from a file called example.txt
:
sed -n '/example/p' example.txt
The output of this command might look like this:
This is an example line
This is another example line
The parts of the command are as follows:
sed
: the command used to stream-edit files-n
: the flag to suppress default output/example/p
: the pattern to match and thep
command to print the lineexample.txt
: the file to be edited
For more information, see the GNU sed manual.
More of Cli Sed
- How can I fix the "cli sed not found" error?
- How can I use sed in a command line interface?
- How do I use sed to add quotes around a string in a command line interface?
- How to use sed to modify Kubernetes configuration files from the command line?
- How do I use Azure CLI to modify strings with sed?
- How can I use the command line to compress and edit files with sed and zip?
- How do I use the command line to edit text using sed?
- How can I use the 'sed' command line utility to group text?
- How can I set up the Xcode command line interface?
- How do I use CLI sed to uninstall a module?
See more codes...