Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.