This command works fine in bash:

bash-3.2$ scp luna4:/u/paige/maye/src/diviner/notebooks/plots/hk_* .
hk_az.png                                                   100%  126KB 126.0KB/s   00:00
hk_baffle.png                                               100%  166KB 166.3KB/s   00:01
hk_bb.png                                                   100%  144KB 143.8KB/s   00:00
hk_el.png                                                   100%  115KB 115.3KB/s   00:00
hk_fpa.png                                                  100%  123KB 123.2KB/s   00:00
hk_fpb.png                                                  100%  126KB 125.7KB/s   00:00
hk_hybrid.png                                               100%   99KB  98.7KB/s   00:00
hk_oba.png                                                  100%  140KB 139.7KB/s   00:00
hk_solar.png                                                100%  206KB 205.6KB/s   00:00
hk_temp.png                                                 100%   62KB  61.8KB/s   00:00
hk_yoke.png                                                 100%  122KB 121.7KB/s   00:00
bash-3.2$ exit

but in zsh it fails, no files are found:

$ scp luna4:/u/paige/maye/src/diviner/notebooks/plots/hk_* .
zsh: no matches found: luna4:/u/paige/maye/src/diviner/notebooks/plots/hk_*

What is going wrong?

migrated from stackoverflow.com Dec 29 '13 at 8:07

This question came from our site for professional and enthusiast programmers.

  • I was wondering myself if it's okay for this to post here, but I searched for zsh and scp and found many entries, none of which marked as 'on hold', otherwise I wouldn't have posted it here. – K.-Michael Aye Dec 22 '13 at 10:41

The problem is that zsh is globbing the remote path. You can verify this by

scp luna4:"/u/paige/maye/src/diviner/notebooks/plots/hk_*" .

To turn globbing off for scp remote paths, but otherwise leave globbing the same (from here) add this to your .zshrc -

# Disable globbing on the remote path.
alias scp='noglob scp_wrap'
function scp_wrap {
  local -a args
  local i
  for i in "$@"; do case $i in
    (*:*) args+=($i) ;;
    (*) args+=(${~i}) ;;
  esac; done
  command scp "${(@)args}"
  • 1
    Cheers. Confirmed. Can I switch that off? – K.-Michael Aye Dec 20 '13 at 19:46
  • 1
    @K.-MichaelAye Edited answer, but yes. – Elliott Frisch Dec 20 '13 at 19:48
  • And that hack also works. Great, thanks! (Added it to my .zshrc) – K.-Michael Aye Dec 20 '13 at 19:51

If you use single quotes, then it works:

scp 'remote.host.com:files*' .
  • I'll +1 you as this was a simple fix in using Cygwin. Thanks! – Carlos Aug 17 '17 at 18:29
  • simple and easy fix. Thanks! no need for further hook. – kate Aug 22 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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