How to replace expressions with embedded blanks
I need to edit myfile in a script.I tried items below but it did not change anything. Thanks again.
myfile: 141 aaaa bb Jun 4'09su Jun15'09mo yyyy 206 vvv nn Jun 4'09su Jun16'09tu tt 208 bb yyyy Jun 4'09su Jun15'09mo vvvvvvvv result: 141 aaaa bb Jun04'09su Jun15'09mo yyyy 206 vvv nn Jun04'09su Jun16'09tu tt 208 bb yyyy Jun04'09su Jun15'09mo vvvvvvvv pdate="Jun 4" pdate1=Jun04 sed 's/$pdate/$pdate1' myfile or sed 's/"$pdate"/$pdate1' myfile |
Code:
sed "s/$pdate/$pdate1/g" myfilep EDIT: What do you mean it did not change anything? Your result is different. If you want to make that changes permanent in your file then use the -i option or redirect output to another file. |
yeah-if you want to edit the file "in place" add the -i, otherwise sed will just print the output and leave the file as-is.
|
Quote:
|
Quote:
If printing on the screen is sufficient then you do not need the -i option. |
Quote:
Code:
c@CW8:~$ echo '141 aaaa bb Jun 4'09su Jun15'09mo yyyy |
Quote:
|
All times are GMT -5. The time now is 06:36 PM. |