Putting Single Quotes in the Output... 
Author Message
 Putting Single Quotes in the Output...


   >None of those will work because convdate requires a ' when there's
   >blank space in the equation.
   >How do I get it to have an output of something like
   >'May  8 09:19'
   >I can figure out the rest, I'm just stumped on this how to have
   >output with a ' in it without screwing up awk.
The problem is that the shell won't allow you to put single quotes inside
single quotes.  There are several ways around this, like writing the awk
script in a separate file using "awk -f", or printf("%c",39), or something
like:
awk '{print "'\''"}'

Net-Tamer V 1.08X - Test Drive



Wed, 06 Mar 2002 03:00:00 GMT  
 Putting Single Quotes in the Output...

Quote:


>   >None of those will work because convdate requires a ' when there's
>   >blank space in the equation.
>   >How do I get it to have an output of something like
>   >'May  8 09:19'
>   >I can figure out the rest, I'm just stumped on this how to have
>   >output with a ' in it without screwing up awk.
>The problem is that the shell won't allow you to put single quotes inside
>single quotes.  There are several ways around this, like writing the awk
>script in a separate file using "awk -f", or printf("%c",39), or something
>like:
>awk '{print "'\''"}'

awk '{print "\039"}'
would also work, replacing the octal number for what you wanted to print.


Wed, 13 Mar 2002 03:00:00 GMT  
 Putting Single Quotes in the Output...
i often do this
BEGIN {q="\"}}

        {print q "hello $1" q}

which makes things a little more readable IMHO

On Sat, 25 Sep 1999 18:30:52 GMT, Ian Stirling

Quote:



>>   >None of those will work because convdate requires a ' when there's
>>   >blank space in the equation.
>>   >How do I get it to have an output of something like
>>   >'May  8 09:19'
>>   >I can figure out the rest, I'm just stumped on this how to have
>>   >output with a ' in it without screwing up awk.
>>The problem is that the shell won't allow you to put single quotes inside
>>single quotes.  There are several ways around this, like writing the awk
>>script in a separate file using "awk -f", or printf("%c",39), or something
>>like:
>>awk '{print "'\''"}'

>awk '{print "\039"}'
>would also work, replacing the octal number for what you wanted to print.

___________________________________________________________________

100 University Drive, Fairmont WV, 26554, USA;  fax +1-304-367-8211
"Computers are useless. They can only give you answers."  --Picasso


Mon, 18 Mar 2002 03:00:00 GMT  
 Putting Single Quotes in the Output...
On Sat, 25 Sep 1999 18:30:52 GMT, Ian Stirling

Quote:

>awk '{print "\039"}'
>would also work, replacing the octal number for what you wanted to print.

Certainly fine solution.  We've covered the following before, but if
you need single quotes frequently, use them directly:

    cat  <<\End-of-Awk  >$TMP.awk;     # make quotes in awk easier
    BEGIN {
       printf("I'm a simple boy\n");
       printf("You'll like easy quoting.\n");
       printf("awk's able to do it fine.\n");
       printf("Can't open file '%s'\n", myfile);
       exit;
       }
End-of-Awk
awk -f $TMP.awk

Where you TMP is defined something like:
   TMP=/tmp/$CMD$$;         # temp file name(s)
    trap 'rm -f $TMP.*;' 0;  # remove temp files when done
    trap 'rm -f $TMP.*; exit 1;' 1 2 3;

I read the FAQ again.  I don't think it is too helpful.  I just posted
my humble "Suggestions for awk FAQ Section 14.2".



Mon, 18 Mar 2002 03:00:00 GMT  
 Putting Single Quotes in the Output...

Quote:

>On Sat, 25 Sep 1999 18:30:52 GMT, Ian Stirling

>>awk '{print "\039"}'
>>would also work, replacing the octal number for what you wanted to print.
>Certainly fine solution.  We've covered the following before, but if
>you need single quotes frequently, use them directly:

I know, but occasionally, there is a situation, which it's handy to
have it all in one file.
If, for example you've got a script, with an awk one-liner, it can
obfuscate the script to seperate out the awk program file, as well as making
it more easy to seperate out the two.


Tue, 19 Mar 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Putting Single Quotes in the Output...

2. Getting awk (or sed or anything else) to put single quotes into file

3. Putting single quotes inside Prolog strings

4. replace single quote to double quote with an example

5. single-quoted string conversion to triple-quoted string

6. How to print out single quoted columns?

7. gawk win32 binary & single quote invalid char

8. Substituting single quotes from Perl via shell using awk and gsub

9. parsing lines with quoted strings as single fields

10. awk not printing single quotes

11. awk: putting quotes around a field value

12. How can I escape the single quote symbol?

 

 
Powered by phpBB® Forum Software