I'm trying to set a variable to a string representing a file's location and when I try to set the variable I keep on getting a 'permission denied' error, because the bash script is trying to execute the file.
Here is the code I'm using
date= 07062011
archive_dir=~/Documents/ABC/Testing
aggregate_file= `echo ${archive_dir}"/"${date}"_Aggregated.txt"`
The error I am getting is the following:
./8000.2146701.sh: line 32: /home/me/Documents/ABC/Testing/20110706_Aggregated.txt: Permission denied
From what I understand using the backticks should allow me to take the output of the command and put it into a variable and it doesn't seem to be working. When I just do the echo statement by itself the output is the file path.
Thanks.
The direct problem is the space following:
aggregate_file=
That is:
aggregate_file= `echo ${archive_dir}"/"${date}"_Aggregated.txt"`
would have worked by simply removing the space after the assignment operator:
aggregate_file=`echo ${archive_dir}"/"${date}"_Aggregated.txt"`
But really it should have just been:
aggregate_file="${archive_dir}/${date}_Aggregated.txt"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With