Reputation: 57
Im trying to parse and insert elements of a file using awk.
clear
MESSAGE=$(cat emailTranscript.txt)
awk -F READLINE="$MESSAGE" 'BEGIN{
FS=","}
{
CURRENTMESSAGE=READLINE
gsub("#FIRSTNAME", $1, CURRENTMESSAGE)
gsub("#LASTNAME", $2, CURRENTMESSAGE)
gsub("#MAJOR", $3, CURRENTMESSAGE)
gsub("#ADDRESS", $4, CURRENTMESSAGE)
print CURRENTMESSAGE "\n--------------------------\n s"
}' nameAddresses.csv
Is there something wrong with the way I'm handling my csv file?
Upvotes: 0
Views: 46
Reputation: 56129
You don't say precisely what you're trying to do, but I can say with a great deal of confidence you are doing it wrong. From your code, I'll guess that emailTranscript.txt
contains a form letter and nameAddresses.csv
contains the data to be substituted in.
The biggest error, and the one I suspect is your problem, is that -F
specifies the field separator. You want -v
, to set a variable.
Upvotes: 2