I'm having some problems running my current program. I need to take a file of customers information (each line is a new customer) and substitute it into a template. Each customer info will created a file from the template and will be named using the customer's email and placed into the Email subdirectory using awk
and sed
. Right now my program is not 'doing anything' except printing the line ./test.bash: line 19: Emails/: Is a directory
.
1 #!/bin/bash
2 set -e
3
4 if [ "$#" -ne 1 ]; then
5 echo "Illegal number of parameters. Usage:./test1.bash <mm/dd/yyyy>"
6 exit 1
7 fi
8
9 OUTPUT_DIR="Emails"
10 details="p4Customer.txt"
11 template="template.txt"
12 date=$1
13 if [ ! -d "$OUTPUT_DIR" ]; then
14 mkdir -p "$OUTPUT_DIR"
15 fi
16
17 gawk -f g2.awk -v date="$date" "$details" | while read detail;
18 do
19 sed "$detail" "$template" > "$OUTPUT_DIR/$email"
20 done;
awk file
1 BEGIN{ FS=",";}
2 {
3 email=$1;
4 fullname=$2;
5 title=$3;
6 n=split(fullname,A," ");
7 name=A[n];
8 amount_owed=$5;
9 if($5>$4)
10 printf "s/EMAIL/%s/;s/FULLNAME/%s/;s/TITLE/%s/;s/NAME/%s/;s/AMOUNT/%s/;s/DATE/%s/\n", email, fullname, title, name, amount_owed, date;
11 }
12 END{}
$email
but not set it to anything? – thrig Oct 10 '17 at 17:48