The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 06-25-2008
figaro figaro is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 268
I am having the following problem when executing this script. It currently looks as follows:

Code:
awk -F, -v dt="$(date "+%Y-%m-%d")" '{ OFS=FS; print "abc", dt, $1 }' foo.csv > foo.txt

The response is "Illegal variable name."

The first few lines of the input file foo.csv look as follows:
SG70,B3B0M92,ANN8132R7036,25-Jun-08
SG68,B3B2J97,ANN8132R6871,25-Jun-08
ST71,B2Q4T68,ANN8132N4540,25-Jun-08
SG67,B3B2J75,ANN8132R6798,24-Jun-08

so it is a list of codes of which the codes in the first column are needed only. Prepended with the code "abc" and the date, the resulting file foo.txt should hold the following data:

"abc",2008-06-25,SG70
"abc",2008-06-25,SG68
"abc",2008-06-25,ST71
"abc",2008-06-25,SG67

How do I correct the code above and preferably still keep everything on one line?

Thanks in advance