Reputation: 51
I am trying to store the output of total count to a variable and then print the variable.
for i in `cat /home/retailer.sh`;do file = "$(grep $i /home/DD.inventory.loaded_master_list.txt|sort -u|wc -l)";echo $file;done
/home/retailer.sh
HAG
GAT
/home/DD.inventory.loaded_master_list.txt
/dailydata_hershey/prd/work/all/2109/delivery/POSDATA_FINAL.GAT.20200201.dat /dailydata_hershey/prd/work/all/2109/delivery/POSDATA_FINAL.HAG.20200201.dat
Below error i get
=: cannot open = (No such file or directory)
Upvotes: 0
Views: 3513
Reputation: 13589
file = "$(...)"
- you have to use file="$(...)"
(no spaces).
Otherwise it will be interpreted as a command. (e.g. file
with an argument of =
)
For future reference, shellcheck.net is a great resource for catching these kinds of things. Just copy-paste your script into the box and it will tell you all of the errors, how to fix them, and a handful of other warnings about potential bugs.
Upvotes: 1