Could you please help me with this task?
"Write a shell script which solve the task without the whereis command. The parameter ($1) is a file name. The script tells you which directories (maybe more than one) does the file exist in. (in the all-time PATH variable)"
So far, i wrote this, but it's totally wrong. My idea was, that the script has to go to the first direvroty, then decide wheter the file is in it or not. Then change to the next directory, do this again, than go back. And do this as many times as much directories i have in the first directory.
However, i'm not allowed to use functions in this task.
#!/bin/bash
cd
for i in $(echo ls | grep -v "..*\..*." | wc -l)
do
cd $(echo ls | grep -v "..*\..*." | cut -f $i")
if [ -e $1 ];
then
echo "exists"
else
echo "does not exist"
let i++
fi
cd
done