0

I'm trying to tftp a bunch of files

tftp -m binary 192.168.1.2 -c put file1 target/file1

I've been trying to use cmd line expansion such as

tftp -m binary 192.168.1.2 -c put `ls *` target/`ls *`

but this doesn't seem to work, a ":" gets inserted after target.

Is there a quick way to expand this kind of stuff?

I want to reuse the values I got in the first expansion into the next expansion

1 Answer 1

4

First of all, `ls *` is wrong. The same intended result can be achieved by using just *, as in:

tftp -m binary 192.168.1.2 -c put * target/

Wildcard expansions are processed by your shell before running the command, so the correct way to expand * to a list of files is to simply use *, never `ls`.


Second, the tftp put command can upload multiple files, but it only accepts a single destination directory when doing so. You don't need to specify multiple targets, and it would not work anyway – tftp wouldn't know where source files end and target files begin. (As said earlier, the wildcards are expanded by your shell, so tftp would receive put file1 file2 file3, not put *.)


The mysterious : is caused by ls listing the contents of subdirectories. When you run ls *, the shell actually runs ls file1 file2 dir1 (let's assume you have two files and a directory). Then ls prints "file1", "file2", followed by "dir1: (...all files in dir1...)".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .