0

下面的脚本工作正常。但是,当我尝试向远程副本添加命令,然后使用从远程副本接收到的文件分配变量 FILENAME 时,while 循环不起作用。我对脚本很陌生,所以我无法找出我缺少的东西。请帮忙!

#!/bin/sh
#SCRIPT:  File processing
#PURPOSE: Process a file line by line with redirected while-read loop.
SSID=$1
ASID=$2
##rcp server0:/oracle/v11//dbs/${SSID}_ora_dir.lst /users/global/rahul/${ASID}_clone_dir.lst
##FILENAME=/users/global/rahul/${ASID}_clone_dir.lst
count=0
while read LINE
do
echo $LINE | sed -e "s/${SSID}/${ASID}/g"
count=`expr $count + 1`
done < $FILENAME
echo -e "\nTotal $count Lines read"
grep -v -e "pattern3" -e "pattern5" -e "pattern6" -e "pattern7" -e "pattern8" -e "pattern9" -e "pattern10" -e "pattern11" -e "
pattern12" ${ASID}_.lst > test_remote.test
4

1 回答 1

0

当您说“while 循环不起作用”时,如果您收到错误消息,您应该将其包含在您的问题中,以便为我们提供线索。

你确定rcp命令成功了吗?完成后文件是否/users/global/rahul/${ASID}_clone_dir.lst存在rcp

顺便说一句,您的while循环效率低下。这应该是等效的:

sed -e "s/${SSID}/${ASID}/g" < "$FILENAME"
count=$(wc -l "$FILENAME" | awk '{print $1}')
echo -e "\nTotal $count Lines read"
于 2013-02-23T07:31:51.297 回答