gpt4 book ai didi

linux - 执行 Linux bash 脚本时出现错误

转载 作者:太空宇宙 更新时间:2023-11-04 10:35:02 25 4
gpt4 key购买 nike

执行文件“handoff”中的脚本时出现以下错误:

sh handoff
'andoff: line 5: syntax error near unexpected token `do
'andoff: line 5: ` do

文件内容如下:

cat handoff
while [ 1 ]; do
credencemove
k=0
for n in `cat credencemove.txt`
do
status[$k]=$n
k=`expr $k + 1`
done
for m in `cat logsequence.lst`
do
status[$k]=$m
k=`expr $k + 1`
done
ls -lrt | grep arch_credence_1 | tail -1 | cut -c 68- | tr -d 'ah_.log.gz' | cut -c -5 > credencereceived.txt
for o in `cat credencereceived.txt`
do
status[$k]=$o
k=`expr $k + 1`
done
clear
tput bold
echo " Received Applied Moved"
echo " ========================"
echo " "
echo " Credence1 -> ${status[6]} \c"
echo " ${status[3]} \c"
echo " ${status[0]}"
tput rmso
echo " "
echo "Waiting 15 Minuites for applying further logs..."
echo "Press ctrl + c to exit"
sleep 900
done

最佳答案

您的 bash 脚本中有回车符 (\r),就像该脚本是在 Windows 文本编辑器上创建的一样。

使用 dos2unix 清理您的脚本。

关于linux - 执行 Linux bash 脚本时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38012077/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com