[英]How to pass an argument in a Bash script?
我正在运行脚本
#!/bin/bash -xv
billseqno=`sqlplus -s /@prod <<EOF
set heading off
set serveroutput off
select max(billseqno) from bc_run where control_group_ind is null;
EOF`
echo "$billseqno"
shark=`rsync --stats --dry-run -ax bill@shark:/home/$billseqno/ /home/temp/ | grep -i "number of files transferred" | cut -c30-`
其中$billseqno
代表一个文件夹名称,它是一个数字。
我的问题是$billseqno
的值没有传递给rsync
路径。
有什么建议我应该怎么做?
谢谢
您可以尝试使用
shark=$(rsync --stats --dry-run -ax bill@shark:/home/"${billseqno}"/ /home/temp/ | grep -i "number of files transferred" | cut -c30-)
看看
我建议您将 SQL 查询更改为如下:
billseqno=$( sqlplus -s replacethis/@prod <<-EOF
set pagesize 0;
set feedback off;
set verify off;
set heading off;
select max(billseqno)
from bc_run
where control_group_ind is null;
exit;
EOF )
shark=$(rsync --stats --dry-run -ax bill@shark:/home/"$billseqno"/ /home/temp/ | grep -i "number of files transferred" | cut -c30-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.