Storing directory as a variable for later use in linux script
bash, linux
Solution
If file name is `new`(not `"new"`), then change
fileA='/home/jacob/Desktop/CS35L/WORK/2/hw/test3/"new"'
to
fileA=/home/jacob/Desktop/CS35L/WORK/2/hw/test3/new
Problem
In my script, I am holding the location (path) of a file as a variable. For example, fileA An example of its contents are fileA=/usr/anotherfolder/somefold/"filenamehere" However, when i call a command on the file in the script such as: cat $fileA or cat "$fileA" I get an error saying the file or directory doesn't exist. If I echo $fileA to see what the output is, and then run a cat manually from the terminal, it works fine, don't know what is going wrong. Any help? Some debug info: - fileA='/home/jacob/Desktop/CS35L/WORK/2/hw/test3/"new"' - echo '/home/jacob/Desktop/CS35L/WORK/2/hw/test3/"new"' /home/jacob/Desktop/CS35L/WORK/2/hw/test3/"new" - '[' '!' -r '/home/jacob/Desktop/CS35L/WORK/2/hw/test3/"new"' ']' For these particular lines Check for readable file ``` echo $fileA if [ ! -r "$fileA" ] then o=`expr $o + 1` echo "$fileA not readable." continue fi ```