The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
If Statement Problem.. LinuxRacr Shell Programming and Scripting 2 02-26-2008 09:47 PM
problem with if statement equality cleansing_flame Shell Programming and Scripting 1 02-12-2008 07:57 AM
if statement problem djt0506 UNIX for Dummies Questions & Answers 4 12-04-2005 05:16 PM
problem with an IF statement hcclnoodles Shell Programming and Scripting 2 04-17-2003 07:53 AM
if statement problem coughlin74 UNIX for Dummies Questions & Answers 1 09-27-2001 01:31 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-24-2008
Registered User
 

Join Date: Apr 2008
Posts: 3
Creating an sql statement from a file. Problem with '

Hi, I am trying to create sql statements from a file, but I have a problem with ':

This is what I do:
cat filex.txt | awk -F: '{print $1,"A","and personnavn like",$5}' | sed -e "s/^/select bruker.brukernavn, person.personnavn from bruker, person where brukernavn like '/" -e "s/$/' and bruker.person=person.id;/"

The output from this is:
select bruker.brukernavn, person.personnavn from bruker, person where brukernavn like 'xxx A and personnavn like XX XXXX' and bruker.person=person.id;

What I would like to have is:
select bruker.brukernavn, person.personnavn from bruker, person where brukernavn like 'xxx' and personnavn like 'XX XXXX' and bruker.person=person.id;

I am trying something like this:
cat filex.txt | awk -F: '{print $1,"\' and personnavn like \'",$5}' | sed -e "s/^/select bruker.brukernavn, person.personnavn from bruker, person where brukernavn like '/" -e "s/$/' and bruker.person=person.id;/"

But no ....
Reply With Quote
Forum Sponsor
  #2  
Old 04-24-2008
robotronic's Avatar
Can I play with madness?
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Try this:

Code:
test ~ $ cat filex.txt
xxx:dummy:dummy:dummy:XX XXX

test ~ $ awk -F: -v v="'" '{ print("select bruker.brukernavn, person.personnavn from bruker, person where brukernavn like "v $1 v" and personnavn like "v $5 v" and bruker.person=person.id;"); }' filex.txt
Reply With Quote
  #3  
Old 04-24-2008
Registered User
 

Join Date: Apr 2008
Posts: 3
It worked!
Thank you.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:09 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0