سؤال

I have simple script below,

if [ ! -e $c ];
then
mkdir "$c"
fi

$c is containing the folder path. I got the error mkdir: command not found. please help me out.

Thanks in advance. Navdeep

هل كانت مفيدة؟

المحلول

can you run mkdir in your login session?

If you can, most probably the problem is caused by PATH in your script, try suing full path:

if [ ! -e $c ];
then
/bin/mkdir -p "$c"
fi

or export PATH first

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
if [ ! -e $c ];
then
/bin/mkdir -p "$c"
fi
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top