Computing.Net > Forums > Unix > awk substitute for quotes

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

awk substitute for quotes

Reply to Message Icon

Name: munkiboy
Date: March 22, 2005 at 09:39:10 Pacific
OS: aix 4.3
CPU/Ram: risc rs6000
Comment:

Hi, I have to enclose some fields in a text file in quotation marks. When I created the file I used the pipe symbol "|" before and after the field intending to change this to quotes. Can anybody please advise me on this, I'm trying to use awk gsub command to do this.
Many thanks, Brian



Sponsored Link
Ads by Google

Response Number 1
Name: Jim Boothe
Date: March 22, 2005 at 11:55:28 Pacific
Reply:

Here are three solutions to change pipe character to a single-quote:

awk 'BEGIN{q="\047"}{gsub("\|",q);print}'

awk '{gsub("\|","'\''");print}'

sed "s/|/\'/g"


0

Response Number 2
Name: munkiboy
Date: March 22, 2005 at 12:43:29 Pacific
Reply:

Hello Jim,
Thanks for that, it's just what I needed. I owe you a beer.
Cheers, Brian


0

Response Number 3
Name: Jim Boothe
Date: March 22, 2005 at 12:53:23 Pacific
Reply:

Great - but I'm free only during the day or at night.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: awk substitute for quotes

gawk/awk for windows www.computing.net/answers/unix/gawkawk-for-windows/1794.html

awk script for search and replace www.computing.net/answers/unix/awk-script-for-search-and-replace/7039.html

awk variable for filename www.computing.net/answers/unix/awk-variable-for-filename/7078.html