![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to print single quote in awk | gauravgoel | UNIX for Dummies Questions & Answers | 6 | 08-20-2008 05:48 PM |
| escaping single quote | javeed7 | Shell Programming and Scripting | 3 | 04-02-2008 06:36 AM |
| single quote | dreams5617 | Shell Programming and Scripting | 2 | 12-01-2007 03:37 AM |
| single or double quote in SED | asami | Shell Programming and Scripting | 2 | 07-17-2006 04:03 AM |
| Replacing a single quote | rjsha1 | Shell Programming and Scripting | 3 | 12-23-2005 10:55 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
AWK handling of single quote
Hi, Can someone let me know how I can acheive the following. I have ~ delimited file and I need to convert into something like SQL insert statements. SrcFile : 1~sjdsdj~asasas~ 2~aaaaa~qwqwqwq~qwq ..... I tried Code:
AWK -F"~" '{print "INSERT INTO XX VALUES("$1 " ,\' "$2" \' , \' "$3 }' SrcFile
However AWK always treat '(single quote) as differently & i guess since single quote appear more than once. Any idea how i can make awk to treat single quote as text character or is this possible in SED? '{print "INSERT INTO XX VALUES("$1 " ,\' "$2" \' , \' "$3 }' |------------------------------------|xxxxxxx|--|xxxxxx| |
|
||||
|
sqlldr will handle this for you - it looks like you're using Oracle. Code:
OPTIONS (DIRECT=false) LOAD DATA INFILE 'myfile' APPEND INTO TABLE MYTABLE FIELDS TERMINATED BY '~' TRAILING NULLCOLS (FLD1, FLD2, FLD3) a ctl file like this one will do what you show. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|