-1

This script tries to copy a text file into another directory. I don't understand why I'm having this problem: ./move_in.sh: line 36: ls: command not found It was working ok until I added the if-statements.

update_file=pwd
echo ""
echo "You can move a text file from your PC into the repository"
echo ""
echo "You need to know where is your text file"
cd /
ls
times=1
echo ""
echo "Where is your text file?"
read directory

while [ -d $directory ]
do
echo $times
if [ $times == 1 ]
then
LAST=$directory
fi

if [ $times != 1 ]
then
LAST=$PATH/$directory
fi

cd $directory
ls
echo ""
echo "Where is your text file?"
read directory
PATH=$LAST
echo $PATH
times=$((times + 1))
done

PATH=$PATH/$directory
echo $PATH
open $PATH
cp $PATH /\$update_file
echo "You found the text file!"
exit 0

I want to have the complete path of the file when the process finishes, thats why I used LAST and PATH, and I equalize them.

user5673573
  • 41
  • 1
  • 7

1 Answers1

1

You are deleting your $PATH use PATH=$PATH: ls is not a builtin command, so it must be in PATH env

user993553
  • 1,077
  • 5
  • 12
  • where am I deleting $PATH? And where do I have to use PATH=$PATH? – user5673573 Oct 13 '16 at 19:07
  • 1
    A better explanation is that `PATH` already has a defined meaning to the shell (it specifies which directories to look in for external commands), and `PATH` (and all all-uppercase variable names) should not be used for your own purposes. – chepner Oct 13 '16 at 19:12