I'm making a shell script to search for files with a specific name and show their full path and size.
For example:
/home/miglui/Desktop/SO/teste/1/teste.txt: 14 bytes
The code of the segment that I'm having trouble is the next:
for i in `find $1 -name $4 -type f -printf "%s "` ; do
path=`readlink -f $4`
echo "$path: $i bytes"
done
The code returns:
/home/miglui/Desktop/SO/teste.txt: 14 bytes
/home/miglui/Desktop/SO/teste.txt: 48 bytes
/home/miglui/Desktop/SO/teste.txt: 29 bytes
But should return:
/home/miglui/Desktop/SO/teste/1/teste.txt: 14 bytes
/home/miglui/Desktop/SO/teste/2/teste.txt: 48 bytes
/home/miglui/Desktop/SO/teste/teste.txt: 29 bytes
What can be the problem?