The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-02-2009
tostay2003 tostay2003 is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 23
single quotes in awk statement

Hi,

I have written a code to modify a string say,

StringA=abc,def,ghi
-->
Code:
StringA=abc,def,ghi
        
I need to change it to something like:

StringB=This means abc='ABC', This mean def='DEF', This means ghi= 'GHI' -->
Code:
StringB=This means abc='ABC', This mean def='DEF', This means ghi= 'GHI'
        
StringB=$(echo $StringA | awk -F',' 'BEGIN { OFS="," } { for (i=1; i<=NF;i++) $i="This means "$i"='ABC'")) THEN '' ELSE " $1 ; print $0 }') -->
Code:
StringB=$(echo $StringA | awk -F',' 'BEGIN { OFS="," } { for (i=1; i<=NF;i++) $i="This means "$i"='ABC'")) THEN '' ELSE " $1 ; print $0 }')
        
I am not able to print the single quotes to the output or rather assign to String B