Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed question

Status
Not open for further replies.

TheDash

MIS
Mar 25, 2004
171
US
sed -e 's/"/'/g' file1.txt >> file2.txt won't work. I am trying to replace all " in the file to '

Any ideas? Thanks.
 
You may try this:[tt]
sed "s!\"!'!g" file1.txt[/tt]

Or this:[tt]
tr '"' "'" < file1.txt[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks. One last question.
Here's a file with records separated with two tabs as shown below. I am trying to replace the tabs with just ", "(comma space)

'aaa' 'bbb'
to
'aaa', 'bbb'

Tried the below lines:
sed 's/[\t]/, /' file1.txt > file2.txt
sed "s/ */, /" file1.txt > file2.txt
They are substituting a character at the beginning of line.

Any help?
 
In a ksh-like shell and with a legacy sed:[tt]
t=$(echo "\t\c") sed "s![ $t][ $t]*!, !" file1.txt > file2.txt[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top