Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to solve the no matches error of the * wildcard when zsh uses the scp command

Shulou Source: shulou.com Published: 2022-06-02 08:51:17 09月28日 Update

This article mainly explains "how to solve the no matches error of the * wildcard when zsh uses the scp command". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow Xiaobian's train of thought to study and learn "how to solve the no matches error of the * wildcard when zsh uses the scp command".

After the upgrade of MacOS, zsh has become the default shell, which conforms to the trend and begins the journey of using zsh.

The following error occurred when copying multiple files remotely using scp today:

# copy all configuration files in a directory (* .conf) scp host:/xxxx/*.conf. # error is as follows # zsh: no matches found: host:/xxxx/*.conf

It is certain that this command statement will work as scheduled in bash, and such a problem should be the fault of zsh. As a veteran linux user, you can quickly see the problem: zsh tried to expand the * wildcard, but the corresponding file was not found locally, resulting in a "no matches" error.

After a personal attempt and online search, there are two solutions:

Do not let zsh expand the *; the specific methods are:

Enclose the * part in quotation marks, single and double quotation marks are meaningless. For example: scp "host:/xxxx/*.conf". Or scp 'host:/xxxx/*.conf'. You can also refer only to the part of the path, for example: scp host:'/xxxx/*.conf'.

Use a backslash to prevent zsh from escaping: scp host:/xxxx/\ * .conf.

Set the nonomatch option so that when a zsh match fails, it does not report an error and uses the original content. To do this: setopt nonomatch, then use the scp command. The recommended practice is to write it to a .zshrc file and let it take effect automatically in future use.

Referenc

The * wildcard cannot be used when zsh uses the scp command

Thank you for your reading, the above is "how to solve zsh using the scp command * wildcard no matches error" content, after the study of this article, I believe you on how to solve the zsh scp command when the * wildcard appears no matches error this problem has a more profound understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Errors commands wildcards files practices content questions learning quotation marks partial personal travel originally multiple that is quickly ideas situations locations articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker macOS Shulou Technology NVidia Shulou Information