Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to tftp a bunch of files

tftp -m binary -c put file1 target/file1

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

tftp -m binary -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

share|improve this question
up vote 4 down vote accepted

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

tftp -m binary -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...)".

share|improve this answer

You must log in to answer this question.

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