问题
Try to find a solution for a problem but stucked with the following :
I have a path of a folder (I got full path and partial path).
Im tying to cd to that folder, but it keep saying "No such file or directory".
Thats the partial code :
for var in "$@" ; do
if [[ -d $var ]] ; then
if [ "$(ls -A $var)" ]; then
cd $var
Would appericiate any help :) Thanks
回答1:
I think this line is your problem:
if [ "$(ls -A $var)" ]; then
Why do you need this test at all? Your previous check looks for the existence of the directory already.
来源:https://stackoverflow.com/questions/16752776/bash-change-directory-inside-a-script-wont-work