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

Say I want to run a program or transfer files over the network using scp, and I create a screen and run those commands in the screen using * to indicate that I want the command to apply to all files in that folder. Does the command only work on the files present at the time when the command was executed, or will it work on files that I later move/copy into the same folder after I have executed the command?

share|improve this question
"Create a screen"? – Ignacio Vazquez-Abrams Jul 9 '13 at 3:32
maybe "open a terminal", Screenmaker :D – mirkobrankovic Jul 9 '13 at 6:09
up vote 5 down vote accepted

I guess he creates a screen session and fires off a long running command like scp or ftp a bunch of files in a folder. While that upload or download is running he adds more files to the source folder/server.

Bash (the shell you are probably running your command with) will only execute the command only on those files that are present at the time of executing the command, because the * character is regarded as a pattern and replaced by the file names matching that pattern.

See man bash

Pathname Expansion

After word splitting, unless the -f option has been set, bash scans each word for the characters *, ?, and [. If one of these characters appears, then the word is regarded as a pattern, and replaced with an alphabetically sorted list of file names matching the pattern.

share|improve this answer

I dont know what you mean by creating a screen either, but it will only be applied to the files present at the time you execute the command.

share|improve this answer
Thanks! By "screen", I meant Linux's screen for remote session management. – Rayne Jul 9 '13 at 3:58

You must log in to answer this question.

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