I have a text file that contains a list of folder names, one per line, that I want to access in a directory. I intend to use the script as follows:
main.sh folderlist.txt foldername/
Here is the code:
#!/bin/bash
DIRFILE=$1;
INPUTBASEDIR=$2;
while read dir; do
echo "$INPUTBASEDIR$dir"
ls -l "$INPUTBASEDIR$dir"
done<"$DIRFILE"
When echoing the concatenated path, it outputs the correct and existing path. However, the ls line spits out : No such file or directory. What must I do to have the second line properly output the files under that directory?