cli-sedHow can I use the 'sed' command line utility to add quotes around a string?
The sed
command line utility can be used to add quotes around a string. The syntax is as follows:
sed 's/^/"/; s/$/"/'
This command will add double quotes around the string. The s
in the command stands for substitute, and the ^
and $
symbols stand for the beginning and end of the string respectively.
The following example will add double quotes around the string Hello World
:
echo "Hello World" | sed 's/^/"/; s/$/"/'
The output of this command is:
"Hello World"
If you want to use single quotes instead of double quotes, you can use the following command:
echo "Hello World" | sed "s/^/'/; s/$/'/"
The output of this command is:
'Hello World'
Helpful links
More of Cli Sed
- How do I use CLI sed to uninstall a module?
- How can I use SED in a Windows command line interface?
- How can I fix the "cli sed not found" error?
- How do I use the CLI to configure Zabbix?
- How can I use CLI sed to create a new VPC?
- How can I use the command line tool sed to create a tutorial?
- How can I troubleshoot when my CLI sed command is not working?
- How can I use the CLI sed command to generate output?
- How can I use sed in the command line on macOS?
- How to use sed in a Jupyter Notebook command line interface?
See more codes...