sed with literal string--not input file
You have a single quotes conflict, so use:
echo "A,B,C" | sed "s/,/','/g"
If using bash, you can do too (<<<
is a here-string
):
sed "s/,/','/g" <<< "A,B,C"
but not
sed "s/,/','/g" "A,B,C"
because sed
expect file(s) as argument(s)
EDIT:
if you use ksh or any other ones :
echo string | sed ...
Using sed command replace in the input text file all occurrences of characters '&', ' ', ' ' with their HTML entities
From info sed
:
3.3 The 's' Command
[...]
The 's' command (as in substitute) is probably the most important in
'sed' [...]. The syntax of the 's' command is 's/REGEXP/REPLACEMENT/FLAGS'.
[...]
The REPLACEMENT can contain [...] unescaped '&' characters which reference the
whole matched portion of the pattern space.
Escape &
with \
to \&
.
find | xargs sed to substitute string in file name instead of file content
Drop the xargs
and -0
's.
find . -type f | sed 's/file//g'
This takes the output of find
and sends it as input to sed
.
Related Topics
Why Doesn't "Total" from Ls -L Add Up to Total File Sizes Listed
Are There Standards for Linux Command Line Switches and Arguments
How to Allocate, in User Space, a Non Cacheable Block of Memory on Linux
Why Redirect Stdin Inside a While Read Loop in Bash
Pattern Match Does Not Work in Bash Script
How to Get the Name of the Current Git Branch into a Variable in a Shell Script
Using 'Date' Command to Get Previous, Current and Next Month
Find a Pattern in Files and Rename Them
Where Are Include Files Stored - Ubuntu Linux, Gcc
How to Check If X Server Is Running
Grep a Large List Against a Large File
Changing Environment Variable of a Running Process
Using Software Floating Point on X86 Linux
Maximum Number of Concurrent Connections on a Single Port (Socket) of Server
View Tabular File Such as CSV from Command Line
How to Convert \Uxxxx Unicode to Utf-8 Using Console Tools in *Nix