Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple quote in awk print 1

Status
Not open for further replies.

loloman

Technical User
Oct 30, 2002
16
0
0
FR
Hy,
I want to display this
select ID from table where IDCOMMANDE = '123';
with awk
my command is :

grep "COMMANDE" $FILE | awk -F";" '{ print "select ID from table where IDCOMMANDE = "$8";"}'

this command display that
select * from table where ID = 123;

how can i display select ID from table where IDCOMMANDE = '123';

thank you
 
Hi

My preferred way :
Code:
grep "COMMANDE" $FILE | awk -F";" [red]-vq="'"[/red] '{ print "select ID from table where IDCOMMANDE = " [red]q[/red] $8 [red]q[/red] ";"}'
Or you can mess with changing or interrupting the quotes.

Feherke.
 
Hi

To show the other alternatives I mentioned :
Code:
grep "COMMANDE" $FILE | awk -F";" [red]"[/red]{ print [red]\[/red]"select ID from table where IDCOMMANDE = [red]'\[/red]"$8[red]\[/red]"[red]'[/red];[red]\[/red]"}[red]"[/red]

[gray]# or[/gray]

grep "COMMANDE" $FILE | awk -F";" '{ print "select ID from table where IDCOMMANDE = "[red]'"'"'[/red]$8[red]'"'"'[/red]";"}'

Feherke.
 
awk -F';' "/COMMANDE/{print \"select ID from table where IDCOMMANDE = '\"\$8\"';\"}" $FILE

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top