Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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)?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

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:

scp remotehost:\*.txt .

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.

share|improve this answer
    
know the option to change the default behavior? –  xenoterracide Jan 9 '11 at 15:30
    
@xeno it's the nomatch, which you unset with the NO_NOMATCH option. In bash there is a failglob option as well. The difference is the default behavior. See zsh.sourceforge.net/FAQ/zshfaq02.html#l9 –  Keith Jan 9 '11 at 17:54
    
you can also put the thing with * in double quotes –  phunehehe Jan 10 '11 at 12:07
add comment

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.