I have the following test.txt file with two lines
keyword 1, 2010-10-01 | 1 | 2 | 3 | 4
keyword 2, 2010-10-01 | 1 | 2 | 3 | 4
and would like to ack for keyword1
and keyword2
. I call this script
#!/bin/bash
OUTPUTPATH=$1"/"
JOB=$2
ID="_"$3".csv"
for keyword in "${@:4}"
do
trKeyWord=$(echo "$keyword" | sed 's/ //g')
ack \""$keyword"\" $JOB > $OUTPUTPATH$trKeyWord$BSLD_ID
done
via
bash script.sh /home/username/ test.txt test "keyword 1" "keyword 2"
The ouput files keyword1_test.csv
, keyword2_test.csv
are created but they are empty! The problem must be how I am using ack \""$keyword"\" $JOB
because just running this command gives an empty result.
Okay guys, this is the final (working) answer: