The other day at work I tried doing
scp remotehost:~/*.txt .
and I received an error about the *
, *.txt file not found
sorry, not at work and I forget the exact error
on my workstation I run zsh
4.3. on the remotehost bash
is the default shell, and the version of zsh
is older (4.2 vs 4.3) on that. I then tried switching to bash on my workstation, and doing the exact same command. This time it worked. What is the root 'cause of this. Is there anyway to do globbing, or wildcards between these 2 systems (without switching to bash)?
Best Answer
zsh's behavior is a little different here than most other shells. Other shells, like bash, try to expand the wildcards. If they cannot expand to anything they pass the literal string (containing the wildcards) to the application instead. But zsh does not do that (well, there is an option for that, to do it or not). The zsh will print that error and not perform the command. You can override that by escaping the wildcard, if you really want it passed to the application. In this case you do since you want the other side shell to expand it. So use:
This is actually the correct behavior, since if you did have some local *.txt files in your home they would be expanded to a name that might not exist on the remote. That's not what you want.