I am trying to find (and store to a variable) the path of a file that is stored on another server by running the following command in one of my functions (included in .bashrc):
FILE_PATH=$(ssh -T user@host 'find <directory> -name *<filename>*')
However this is not returning any output. I have checked that there should be a file in the location that is grabbed, and I have also been able to replicate the command and store output to variable on the command line, but it does not work when running the function.
Does anyone know what's going on and why the command isn't working?
EDIT:
Here is a representation of what I am seeing:
function get_path {
FILE=$1
FILE_PATH=$(ssh -T user@hostB 'find /home/daverbuj -name *${FILE}*')
echo "Here is the file: ${FILE_PATH}"
}
[daverbuj@hostA]$ FILE_A=$(ssh -T user@hostB 'find /home/daverbuj -name foo.bar')
[daverbuj@hostA]$ echo $FILE_A
/home/daverbuj/foo.bar
[daverbuj@hostA]$ get_path foo.bar
Here is the file:
I am seeing what I expect when I run from the command line, but not when I run the function.