We help IT Professionals succeed at work.

replace value with another value that has a space in the value

bje
bje asked
on
Working on replacing a value with another value that has a space in it.   the values are comma separated, so i am using the comma as part of the string that i am looking for

sed s -e '/\,value1,/\,value2 value2,/g' filename > newfilename

the second value has a space in it


Thanks in advance for the help
Comment
Watch Question

ozo
Most Valuable Expert 2014
Top Expert 2015
Commented:
sed -e 's/,value1,/,value2 value2,/g' filename > newfilename
Most Valuable Expert 2013
Top Expert 2013
Commented:
sed -e 's/,value1,/,value2 value2,/g' filename > newfilename
bje

Author

Commented:
thanks for correcting my syntax.

Another sed question, having trouble combining two sed commands into one

sed -e 's/\-/\/g' -e 's/\&/\/g' filename > newfilename

this will not remove both values.

Thanks
ozo
Most Valuable Expert 2014
Top Expert 2015
Commented:
sed -e 's/-//g' -e 's/&//g'  filename > newfilename

or
sed -e 's/[-&]//g' filename > newfilename
To remove individual characters, you can use "tr"

    tr -d '&-' < filename > newfilename
bje

Author

Commented:
Thank you