102

when I try scp over zsh, I get

scp hostA:Descargas/debian-6.0.4-* user@192.168.1.154:Escritorio/Software/
zsh: no matches found: hostA:Descargas/debian-6.0.4-*

the same command work in bash

kopischke
  • 2,226
  • 19
  • 27
juanpablo
  • 6,966
  • 11
  • 52
  • 72

6 Answers6

174

Escape your wildcard :

scp hostA:Descargas/debian-6.0.4-\*
yPhil
  • 2,451
  • 1
  • 19
  • 19
36

or add this to your .zshrc

alias scp='noglob scp'
Per Hurtig
  • 461
  • 4
  • 2
11

Too late for the party, but..

You can escape the string with quotes too

scp "hostA:Descargas/debian-6.0.4-*" "user@192.168.1.154:Escritorio/Software/"
waghcwb
  • 211
  • 2
  • 3
5

Unset the NOMATCH option so that zsh leaves the text alone instead of complaining about a glob failure.

Ignacio Vazquez-Abrams
  • 111,361
  • 10
  • 201
  • 247
5

This post has a nice solution to this by using the url-quote-magic plugin to automatically escape globs in scp commands. To enable it, add the following to your ~/.zshrc:

# Automatically quote globs in URL and remote references
__remote_commands=(scp rsync)
autoload -U url-quote-magic
zle -N self-insert url-quote-magic
zstyle -e :urlglobber url-other-schema '[[ $__remote_commands[(i)$words[1]] -le ${#__remote_commands} ]] && reply=("*") || reply=(http https ftp)'

When you type a glob character (like *) as part of a remote path in an scp or rsync command, zsh will automatically add a blackslash in front, like this:

scp hostA:Descargas/debian-6.0.4-\* user@192.168.1.154:Escritorio/Software/
mgorven
  • 2,807
  • 1
  • 23
  • 26
1

I used to alias no "noglob scp" in my MacOS but with some updates I had always to type \scp at the beginning of the command so wildcards were accepted.

Changed to alias scp="\noglob scp" and it all work, with or without wildcards on command line.

TheUnF
  • 11
  • 2