Вопрос

That's all. They just won't work for me. What did I do wrong this time?

    # nquo is: /home/bryan/renametest/C D/y z

    # script:
    dirn=dirname "$nquo"
    echo "dirn $dirn"
    bnam=basename "$nquo"
    echo "bnam $bnam"

Run result:

    ./script3.sh: 208: /home/bryan/renametest/C D/y z: Permission denied
    dirn 
    ./script3.sh: 208: /home/bryan/renametest/C D/y z: Permission denied
    bnam 
Это было полезно?

Решение

As it stands, your script is trying to run the file named in $nquo first with the environment variable dirn set to the value dirname, and then with the variable bnam set to the value basename. Since it is not executable, you get the error message about not being able to execute the file.

You presumably intended to run the commands on the name of the file, which requires either back-ticks or (preferably) $(...) around it:

dnam=$(dirname "$nquo")
bnam=$(basename "$nquo")
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top