문제

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