我下面有个剧本--
#!/bin/bash
INPUT=/cygdrive/c/apps/dcm4che-2.0.25-bin/SUID_TEST
BASEDIR=/cygdrive/c/apps/dcm4che-2.0.25-bin/bin
TWIDDLE=/cygdrive/c/apps/dcm4chee-2.17.2-mssql/bin/twiddle.sh
#Administrator login and password
LOGIN=mylogin
PASSWORD=mypass
count=0
exec 3<&0 # Save stdin to file descriptor 3.
exec 0<$INPUT # Redirect standard input.
while read line
do
input1=$(echo $line | awk '{ print $1}')
echo "Deleting :" ${input1}
$TWIDDLE -u ${LOGIN} -p ${PASSWORD} -s jnp://192.168.50.51:1099 invoke "dcm4chee.archive:service=ContentEditService" purgeStudy ${input1}
count=$( expr $count + 1 )
sleep 30
done
exec 0<&3 # Restore old stdin.
echo "Counter:" $count # Show deleted items输入文件“SUID_TEST”中将有超过100,000行,每一行看起来都类似于SUID_TEST
我要做的是让脚本只读50行,睡10分钟,继续读50行,睡10分钟,直到它到达输入文件的末尾。
现在,它只运行到文件的末尾。
有人能帮我解决这个问题吗?
谢谢
-只是在这里放一些代码-我正在使用的新脚本:
#!/bin/bash
INPUT=/cygdrive/c/apps/dcm4che-2.0.25-bin/SUID_TEST
BASEDIR=/cygdrive/c/apps/dcm4che-2.0.25-bin/BIN
TWIDDLE=/cygdrive/c/apps/dcm4chee-2.17.2-mssql/bin/twiddle.sh
LOGIN=mylogin
PASSWORD=mypass
cnt=0
count=0
exec 3<&0 #Save stdin to file descriptor 3.
exec 0<$INPUT #redirect standard input
while read input1 rest # Let read split the line instead of running awk
do
echo "Row $count"
((cnt++))
echo "Deleting :" ${input1}
$TWIDDLE -u ${LOGIN} -p ${PASSWORD} -s jnp://192.168.50.51:1099 invoke "dcm4chee.archive:service=ContentEditService" purgeStudy ${input1}
((count++))
if (( cnt == 50 )); then
echo "Sleeping for 10 minutes on" | date
sleep 600
cnt=0
fi
done
exec 0<$3
echo "Counter:" $cnt #show deleted items发布于 2014-04-25 19:10:47
只需数你的循环迭代,睡眠和重置计数器时,它达到50。
cnt=0
count=0
while read input1 rest # Let read split the line instead of running awk
do
echo "Row $count"
((cnt++))
echo "Deleting :" ${input1}
$TWIDDLE -u ${LOGIN} -p ${PASSWORD} -s jnp://192.168.50.51:1099 invoke "dcm4chee.archive:service=ContentEditService" purgeStudy ${input1}
((count++))
if (( cnt == 50 )); then
date
sleep 600
cnt=0
fi
done为了消除对exec语句的需求,只需从不同的文件描述符(习惯上是3 )读取read命令,然后将输入文件重定向到while循环的文件描述符3。
while read -u3 input1 rest; do
...
done 3< "$INPUT"https://stackoverflow.com/questions/23300981
复制相似问题