When I run the following command in the shell it works fine. It prints a city name and then a path for a file.
~$ for i in `awk -F':' '{print $0}' /home/knoppix/Desktop/data/subs | grep -m 1 $ city | sed "s/:/ /"`
>do
>echo $i
>done
Now, when I place it in this shell script (sh) it prints the first entry, a city name, but it just give me blank for the path.
for sub in `awk -F':' '{print $0}' $datsub | grep -m 1 $city | sed "s/:/ /"g`
do
if [ "`echo $sub`" == "`echo $city `" ]
then
echo "Substituting files in $projectname now"
elif [ "`echo $sub | grep .jpg`" ]
then
cp -r $sub $projectname/images
echo "$sub replaced"
elif [ "`echo $sub | grep .gif`" ]
then
cp -r $sub $projectname/images
echo "$sub replaced"
elif [ "`echo $sub | grep .png`" ]
then
cp -r $sub $projectname/images
echo "$sub replaced"
else
cp -r $sub $projectname
echo "$sub replaced"
fi
done
I'm really confused as to why. I know it's getting to the entry, I don't know why it's printing blank. I even tried escaping the "/" characters and all it did was print them as well.
The subs file is written like:
City1:/home/knoppix/subs/file1
City2:/home/knoppix/subs/file2
City3:/home/knoppix/subs/file3
...