#!/bin/bash
#
echo $PWD
cd /home/<my username>/<long path>
echo $PWD
What I get when executing it with bash script.sh
:
/home/<my username>
: No such file or directorye/<my username>/<long path>
/home/<my username>
Or with bash . script.sh
.: .: is a directory
It looks like in first case it has just skipped first 4 characters (/hom
) of the address line for no reason.
And in second case, what the hell is .: .:
? It's absolutely "ungooglable".
And ofc when I copypaste this line cd /home/<my username>/<long path>
in terminal it works like it should.
EDIT: IT WAS ALL ABOUT ONE MISSING SPACE SYMBOL AT THE END OF THE PATH, THANK YOU.
Try sourcing the script using
– Zwans Dec 28 '16 at 16:08.[space]script.sh
cat -net script.sh
and include the output in your question. – steeldriver Dec 28 '16 at 16:17bash . script.sh
you are asking bash to execute the current directory passingscript.sh
as$1
. At the risk of confusing things more, probably what was being asked of you was. script.sh
(without bash) or just possiblebash -c ". script.sh"
. – icarus Dec 28 '16 at 16:19\r
character somewhere in there (did you maybe edit this from Windows?) and that's why it's eating the first few characters but I can't be sure unless you upload the script somewhere and link it here. – terdon Dec 28 '16 at 17:00