The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Double quotes or single quotes when using ssh? password636 Shell Programming and Scripting 3 05-29-2008 08:52 PM
echo using single quotes chella Shell Programming and Scripting 3 10-29-2007 12:54 AM
Checking Single Quotes in C janemary.a High Level Programming 3 06-07-2007 02:48 AM
im stuck! 'single quotes' satnamx UNIX for Dummies Questions & Answers 4 03-29-2006 06:44 AM
Filename containing Single Quotes phani Shell Programming and Scripting 6 03-30-2005 06:47 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-11-2008
orahi001 orahi001 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 48
awk to print ' (single quotes)

I'm building a file with sql delete statements. I need to print the single quotes for the where clause.

i.e.
delete from Command where CommandName = 'SomeName';

I have the following in my script

input=$(pwd)/Cmnd.csv

i=0

while read line
do
if test $i -ge 1;
then
echo "$line" | awk -F'|' '{print "delete from Command where CommandName='"$1"';}' >> deleteCmd.dat

fi

i=$i+1
done < $input

This gives me:
delete from Command where CommandName=;

how do I print the (single quotes) ' with awk?
  #2 (permalink)  
Old 03-11-2008
ShawnMilo ShawnMilo is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 252
In Perl, you have to replace it with:

Code:
\047
I saw something on Google which showed this in awk:

Code:
\47
And for what it's worth, this prints a single quote in bash:

Code:
 $ echo -e "\047"
'
  #3 (permalink)  
Old 03-11-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
Code:
echo "FirstName|LastName" | awk -F"|" '{print "delete from Command where CommandName=\047"$1"\047"}'
delete from Command where CommandName='FirstName'
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0