I have a folder that contains several subfolders, such as PROGRAMME, containing the scripts and URLS, containing the pure text files and TABLEAUX is the subfolders for output.
Now I need to ls the subfolder URL and write to the subfolder TABLEAUX. However, when I use the function ls in for loop, it's said:
ls: cannot access 'URLS': No such file or directory
I guess it's because that the script and the subfolder are not in the same place and I've changed the directory to where the script is (if not, I can't execute the script.) like it shows in the image 2.
And my codes are here:
#command: bash <name of script.sh> <folder_input> <folder_output>
dossier_url=$1
dossier_tableaux=$2
echo $dossier_url
echo $dossier_tableaux # it's ok until here
for fichier in $(ls $dossier_url); do
echo $fichier;
done # Ubuntu shows "ls: cannot access 'URLS': No such file or directory"
CodePudding user response:
Sauvé !
I shouldn't change directory to PROGRAMMES but should use the command:
bash PROGRAMMES/<name of scipt.sh> <input> <output>