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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk in shell script - want to put in a single quote before field!!

Status
Not open for further replies.

LGJ

Programmer
Mar 7, 2003
50
GB
I am trying to create a file to then view in excel. I am extracting data from one file (comma seperated) and sending the required fields to another in a .ksh shell script

the below works fine but if I want to put a single quote (') before $2 how is this done? I've tried various ways and get syntax errors saying its unmatched

OK :-
cat dummydata | awk -F, '{ print $1"\t"$2"\t"$3"\t"$4 }' >> ${FILE}_${TIMESTAMP}.xls

Gives errors :-
cat dummydata | awk -F, '{ print $1"\t'"$2"\t"$3"\t"$4 }' >> ${FILE}_${TIMESTAMP}.xls

 
Try this:
Code:
awk -F, '{print $1"\t'"'"'"$2"'"'"'\t"$3"\t"$4}' dummydata >> ${FILE}_${TIMESTAMP}.xls

Hope This Help
PH.
 
Great , thanks PH this does the trick, not too sure how it works though?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top