本文介绍了脚本文件VS命令行:rsync的和--exclude的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的测试bash脚本看起来像:

I have a simple test bash script which looks like that:

#!/bin/bash

cmd="rsync -rv --exclude '*~' ./dir ./new"
$cmd # execute command

当我运行该脚本,它也将复制与结尾的文件一个尽管我的意思是将它们排除在外。当我直接在命令行中运行同样的rsync命令,它的作品!是否有人知道为什么,以及如何使bash脚本的工作?

When I run the script it will copy also the files ending with a ~ even though I meant to exclude them. When I run the very same rsync command directly from the command line, it works! Does someone know why and how to make bash script work?

顺便说一句,我知道我还可以工作 - 排除 - 从,但我想知道这是如何工作反正

Btw, I know that I can also work with --exclude-from but I want to know how this works anyway.

推荐答案

尝试评估

#!/bin/bash

cmd="rsync -rv --exclude '*~' ./dir ./new"
eval $cmd # execute command

这篇关于脚本文件VS命令行:rsync的和--exclude的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 18:33