How to remove any space around a specific charachter from a string using sed.
for exmple :
the string is like following
str1='"name", "roll", "addr","job", "pay",'
I need to remove all the spaces aronnd the commas.
How to remove any space around a specific charachter from a string using sed.
for exmple :
the string is like following
str1='"name", "roll", "addr","job", "pay",'
I need to remove all the spaces aronnd the commas.
simplest usage
# sed 's/ "/"/g' infile
echo "$str1" | sed 's/ *, */,/g'
its giving the message :
try.sh[7]: str4=${echo $str1 | sed "s/ *, */,/g"}: bad substitution
Hi, use $( )
instead of ${ }
(and use double quotes around $str1)
with tr ..
echo "$str1"|tr -d " "
Try with ( )
str4=$(echo $str1 | sed "s/ *, */,/g")
Thanks a lot guys..it worked....
but, caqn you please explain why we are using () instead of {}?