this is a nice way to do something with files in directory...
Code:
for i in $( ls /root/Desktop );
do
done
but the problem is when files have spaces in their names, then variable "i" becomes, first the first part of the name of the file(before space) and the second part(after space), i wrote few more lines to avoid that.
Code:
for i in $( ls /root/Desktop );
do
direktorij1=/root/Desktop/$i
echo $direktorij1
echo $direktorij2
if [ -d "$direktorij1" ];
then pitanje $direktorij1
elif [ -e "$direktorij1" ];
then echo aa
else
if [ -e "$direktorij2" ];
then direktorij2=$direktorij1;
else direktorij2="$direktorij2 $i"
echo $direktorij2
if [ -d "$direktorij2" ];
then pitanje "$direktorij2"
fi
fi
fi
done
Note that it works only for folders because i need to call function "pitanje" for every folder in a folder /root/Desktop (/root/Desktop is just an example)
So the question is can all this be avoided by editing "for loop" or simplified the other way.