The runtime arguments are as follows: $1 is the path to the file containing the list of files$2 is the path to the directory containing the filesWhat I want to do is check that each file listed in $1 exists in the $2 directoryI'm thinking something like:for f in 'cat $1'doif (FILEEXISTSIN$2DIRECTORY)then echo '$f exists in $2'else echo '$f is missing in $2' sleep 5 exitfidoneAs you can see, I want it so that if any of the files listed in $1 don't exist in the directory $2, the script states this then closes. The only part I can't get my head around is the (FILEEXISTSIN$2DIRECTORY) part. I know that you can do [ -e $f ] but I don't know how you can make sure its checking that it exists in the $2 directory.Thank you, I hope you can help this bash noob out.
Check whether files in a file list exist in a certain directory
bash;shell;files;scripting
The best way to iterate over the lines in a file is using the read builtin in a while loop. This is what you are looking for:while IFS= read -r f; do    if [[ -e $2/$f ]]; then        printf '%s exists in %s\n' $f $2    else        printf '%s is missing in %s\n' $f $2        exit 1    fidone < $1