awk scripting problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk scripting problem
# 1  
Old 05-09-2002
awk scripting problem

I'm creating an oracle insert statement using awk but need to be able to escape the ' (forward single quote) as the oralce insert syntax requires these quotes. I've tried \ in and out of quotes etc.
It's these single quotes values (' .....')


cat $1 | awk -F"|" '{print "insert into table (data_string) values ('PRICES|"$6"|FOSTRAT|"$24"|||N');"}'


Any ideas anyone ?
# 2  
Old 05-09-2002
What happen if you create an awk file:

my_awk.awk
{
print "insert into table (data_string) values 'PRICES|"$6"|FOSTRAT|"$24"|||N');"
}


cat $1 | awk -F "|" -f my_awk.awk

Regards. Hugo.
# 3  
Old 05-15-2002
For this to work you also have to ensure that all single quotes in the data are duplicated. Try this:

Code:
sed -e "s/'/''/g" $1 | awk -F"|" '{
    printf "insert into table (data_string) values "
    printf "(%cPRICES|%s|FOSTRAT|%s|||N%c);\n", 39, $6, $24, 39
}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Scripting awk Problem

I'm limited in my skills related to *nix and I'm even more limited in my skills related to shell scripting and the use of awk. I have what should be a relatively simple shell script that looks in the /etc/fstab to see if a particular partition exists on the Linux system. The intention of this part... (2 Replies)
Discussion started by: DisabledVet
2 Replies

2. Shell Programming and Scripting

Scripting with awk: facing problem

Hi, I wants to print the 9th column information with its path name in some txt file. Here is one line which works fine for me: rfdir /castor/cern.ch/user/s/sudha/forPooja | grep data | awk '{print "rfio:///castor/cern.ch/user/s/sudha/forPooja/"$9}' > dataFilenames.list rfdir=="ls -ltr" ... (2 Replies)
Discussion started by: nrjrasaxena
2 Replies

3. Shell Programming and Scripting

Scripting problem

I have one table contains the last field is gender and it is entered in small letter ,i would like to convert to caps after checking the field? eg: eno ename loc gender 1 a ch f 2 b hy M 3 c hy m 4 d ... (1 Reply)
Discussion started by: mrbinoy
1 Replies

4. Shell Programming and Scripting

Scripting Problem

Hello guys, I am a newbie to Shell Scripting. I have an issue. My requirement is to search a pattern in a file and then replace it with another pattern. Please note that I have thousands of files having the same pattern and I have to replace it running a script. I have created a script as shown... (4 Replies)
Discussion started by: mahesh_raghu
4 Replies

5. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies

6. Shell Programming and Scripting

scripting problem

I am trying to write a script that tells us whether the permissions for two files, whose names should be given as arguments to the script, are identical. And if the permissions for the two files are identical, have to output the common permission field. or else output each filename, followed by... (0 Replies)
Discussion started by: manojrsb
0 Replies

7. UNIX for Advanced & Expert Users

scripting problem

hI I m very new to unix ,... I m facing an issue I have to search though a list of directorys, find all .gz files which are older than 7 days and delete that ,,, Any one knows a single command to do this .. Thnks in advance BInu (3 Replies)
Discussion started by: msbinu
3 Replies

8. Shell Programming and Scripting

AWK scripting problem - appending values

ABC:10:A1:ABCA110 ABC:10:A1:ABCA110 ABC:20:A1:ABCA120 DEF:20:D1:DEFD120 GHI:30:G1:GHIG130 GHI:40:G1:GHIG140 JKL:30:J1:JKLJ130 MNO:10:M1:MNOM110 What I'm trying to do is look through a file that consists of four columns (as above). As you can see there are duplicates in the file, i.e.... (2 Replies)
Discussion started by: rowntree
2 Replies

9. Shell Programming and Scripting

scripting problem

I hv the below script , that is work fine on unix sytem ( ksh ) , but it is not work in my RH system , the script can kill the idle user who have idel for 120 minutes but exclude the user in the exception.lst the error happen when run the statemnt " (( time = $TIMEOU + 1 )) " , could suggest... (3 Replies)
Discussion started by: ust
3 Replies

10. Shell Programming and Scripting

Scripting problem

I'm hoping one of you scripting experts can help me. I'm trying to find out the IP Address of every printer on my HP-UX server. (There's 256 of them) I'm trying to do it using the PERIPH= value in /etc/lp/interface/<printername>, but I'm having problems scripting it as I'm a bit of a newbie. ... (2 Replies)
Discussion started by: Robin
2 Replies
Login or Register to Ask a Question