TFTP an entire directory, problem with spaces in names

busyboxtftp

I've done a bit of digging, but I haven't discovered a working solution yet (to my surprise.) I've been trying this:

# for i in `ls`; do tftp -l "$i" -p 192.168.1.100; done

I just want to TFTP the contents of an entire directory (without tar/zipping them up). The problem is, of course, spaces in file names break everything. Maybe I should be using some other strategy?

Shell scripting isn't exactly my strong point…

(Extra points (not really) if there is a working recursive solution.)

Best Answer

Type

IFS=$(echo -en "\n\b")

before executing your loop, this will fix file name problem.

If you want to recursively tftp files use the following -

find . -print0 | while read -d $'\0' i
do
   tftp -l "$i" -p 192.168.1.100
done