Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

OT: Unix shells and the single quote char (Was: Re: Why won't this AWK work to create SQL with Today
In article <3brmmpF6hqjarU1@uni-berlin.de>,
Patrick TJ McPhee <ptjm@interlog.com> wrote:
>In article <ei2g5155c4guh15v04ckn1o13mpqr2lmns@4ax.com>,
>Brian Inglis  <Brian.Inglis@SystematicSW.ab.ca> wrote:
>% On 8 Apr 2005 03:00:49 GMT in comp.lang.awk, ptjm@interlog.com
>% (Patrick TJ McPhee) wrote:
>%
>% >Printing ' can be problematic in an awk script which is passed as an
>% >argument.
>%
>% Not too hard: just replace each embedded "'" with "'''".
>
>You could do this, but it won't solve the problem with the majority of
>Unix shells. It can be problematic.

No, the method is to replace each embedded ' with '"'"' (5 alternating
quote marks).  I think what you (Patrick) are getting at is that methods
using \s are unreliable - and this agrees with my experience.

I just tested this shell command:

gawk 'BEGIN {print "'"'"'","is a single quote"}'

under tcsh, sh, and ksh - and got the same (correct) result each time.

Note that, for real life AWK/shell scripting, the \047 method is easier.
In the \047 method, the above would be written:

gawk 'BEGIN {print "\047","is a single quote"}'

P.S.  The "5 quote" method is handy to know when writing csh aliases.


Report this thread to moderator Post Follow-up to this message
Old Post
Kenny McCormack
04-12-05 01:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:12 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.