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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

escape single tic ' 1

Status
Not open for further replies.

grazinggoat

Programmer
Mar 12, 2008
41
US
this is more a sed question

I am trying to remove a single tic from around a word in a file..

'word'

I'm doing the following:

sed 's/\'//g' nfile > ofile

But its not reading.

Trivial but I'm having no luck. thoughts please?
 
Hi

While you asked in the [tt]awk[/tt] forum let us start with some [tt]awk[/tt] solutions :
Code:
awk "{gsub(/'/,\"\")}1" nfile > ofile

awk -vq="'" '{gsub(q,"")}1' nfile > ofile
Tested with [tt]gawk[/tt] and [tt]mawk[/tt].

And the off-topic solutions ( which probably can be found in old post in forum822 ) :
Code:
sed "s/'//g" nfile > ofile

sed 's/'"'"'//g' nfile > ofile

tr -d "'" < nfile > ofile
Tested with GNU [tt]sed[/tt] and GNU [tt]tr[/tt].

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top