hwo do I print ' in an awk statment?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users hwo do I print ' in an awk statment?
# 1  
Old 11-30-2006
hwo do I print ' in an awk statment?

hi 2 all,
I'm trying 2 print " ' " in an awk statement but the sign deosn't show.
The only way I came with is 2 declare the ' as a variable and call that variable.
I'm trying 2 do:
awk '{printf("insert into ba_memo_01 values ('%s');",$1)}'

and get the output:
insert into ba_memo_01 values ('627562');

thanks
# 2  
Old 11-30-2006
who do I print ' in an awk statement?

hi 2 all,
I'm trying 2 print " ' " in an awk statement but the sign deosn't show.
The only way I came with is 2 declare the ' as a variable and call that variable.
I'm trying 2 do:
awk '{printf("insert into ba_memo_01 values ('%s');",$1)}'

and get the output:
insert into ba_memo_01 values ('627562');

thanks
# 3  
Old 11-30-2006
awk '{print "insert into ba_memo_01 values('627562');"}'

works good for me

John
# 4  
Old 11-30-2006
it doesn't work it prints:
insert into ba_memo_01 values(627562);
withuot the '
# 5  
Old 11-30-2006
Try...
Code:
awk '{printf("insert into ba_memo_01 values (\047%s\047);",$1)}'

# 6  
Old 11-30-2006
Computer

thanks it worked beautifully Smilie
# 7  
Old 11-30-2006
Just a round about way,

modify the source file to hold quotes,
123 -> '123'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add new line after 'continue' in if statment

Hello, im creating a csv file for email reporting on issues. my problem is that after 'continue' command in if statment in a loop the new paramter writing into the log doesnt take new line. timeout 4s zabbix_get -I $ZBX -p $PORT -s $IP -k "system.run" if ; then ... (3 Replies)
Discussion started by: batchenr
3 Replies

2. Shell Programming and Scripting

Wildcard in a tcsh if statment

Hello everyone I was hoping someone could tell me whether I can use a wildcard inside an tcsh if statement. I am trying to test the argument the user has fed the script and whether it is a .txt file. The Ides behind it is the following if (`echo $1` != *.txt) then echo "wrong... (6 Replies)
Discussion started by: smarones
6 Replies

3. UNIX for Dummies Questions & Answers

ping is blocked hwo to check connection

Hi How to check connection with another IP/Server not using ping? Thanks (5 Replies)
Discussion started by: miojamo
5 Replies

4. Shell Programming and Scripting

-F option and - V in a single awk statment

Please let me know if I can use -F option and - V in a single awk statment. I want to import some comma separated shell variables using -F option and defining some static variables inside awk using -v option. (2 Replies)
Discussion started by: kalee
2 Replies

5. UNIX for Dummies Questions & Answers

Comparing Special characters (i.e. -,\,/) in an if statment

I need to validate the special characters of a date (the characters between the year and month & month and day). The data filed is being populated by users and read into the script vi an argument. I want to ensure that the date is a '-' (dash) and not a '/' or '\' (slash). The every thing I... (3 Replies)
Discussion started by: angelap
3 Replies

6. UNIX for Dummies Questions & Answers

Clarification for egrep statment

Can someone tell me what exactaly the following command is doing - pid_cmd="/usr/ucb/ps -axww | /usr/bin/egrep '${SUNMC2OSS_PATH}/SunMC2OSS\.jar.* sunmc2oss\.SunMC2OSS\$' | /usr/bin/egrep -v egrep | /usr/bin/nawk '{print \$1}'" Is the egrep is to check "sunmc2oss.SunMC2OSS" process inside... (2 Replies)
Discussion started by: puneet1983
2 Replies

7. Shell Programming and Scripting

if statment, based on retune value

hello im working on a project for the iphone to write a termainal based program we have bsd subsystem installed so have access to most unix command i have a executable called coordinates, which get the coordinates of the iphone when this runs it returns to the terminal the text of... (1 Reply)
Discussion started by: toliver182
1 Replies

8. Shell Programming and Scripting

what is wrong with my awk statment?

I am looking to find something in the hour(in field $2) of 03:00:07 and 04:00:07 and 05:00:07 and must contain something in field 4... why doesn't below command work? I try to use grep .. but since I am running this in loop, it's best I use the awk .. can someone please advise.. I am pretty... (1 Reply)
Discussion started by: hankooknara
1 Replies

9. Shell Programming and Scripting

hwo 2 send information from unix 2 URLs

hi, I have a script that creates a table, I'd like 2 send the last entrance of this table to a url form and activate this form. Does anyone know if it can B done? :rolleyes: (0 Replies)
Discussion started by: baraka
0 Replies

10. Shell Programming and Scripting

How do I get awk to print a " in it's print part?

The line is simple, use " '{ print $1"]"$2"\"$3THE " NEEDS TO GO HERE$4 }' I've tried \", "\, ^" and '"" but none of it works. What am I missing? Putting in the [ between $1 and $2 works fine, I just need to do the same with a ". Thanks. (2 Replies)
Discussion started by: LordJezo
2 Replies
Login or Register to Ask a Question