rsync在shell for循环中 [英] rsync in shell for loop
本文介绍了rsync在shell for循环中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#!/ bin / sh
PATHS =(abcd)
PATH $ {PATH [$]
rsync -avziP / home / user / $ PATH $ SERVER:$ server_folder -b --backup-dir = $ backup_folder / backup_ $ date --delete --exclude =。* --log-file = $ HOME / rsync.log
完成
而我总是得到这个错误:
lockquote
rsync:找不到命令
让我疯狂的是,如果我删除了for循环,并且运行rsync命令,那么脚本完美地工作了。
解决方案
PATH
是一个保留的变量!
是指定在哪里搜索工具的变量(如 rsync
)
$设置| grep ^ PATH =
PATH = / home / user / bin:/ usr / local / bin:/ usr / bin:/ bin:/ usr / local / games:/ usr / games
使用另一个变量名称!
I have this shell script
#!/bin/sh
PATHS=( a b c d )
for PATH in ${PATHS[@]}
do
rsync -avziP /home/user/$PATH $SERVER:$server_folder -b --backup-dir=$backup_folder/backup_$date --delete --exclude=.* --log-file=$HOME/rsync.log
done
And I always get this error:
rsync: command not found
What is driving me crazy is that if I delete the for loop, and just run the rsync command, the script works perfectly
解决方案
PATH
is a reserved variable!
It is the variable specifying where to search tools (like rsync
)
$ set | grep ^PATH=
PATH=/home/user/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Use another variable name!
这篇关于rsync在shell for循环中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文