all.log awk -F ' ' '{print }' all.l-6ren">
gpt4 book ai didi

linux - 需要帮助解决 "unexpected end of file"异常?

转载 作者:太空宇宙 更新时间:2023-11-04 12:47:03 24 4
gpt4 key购买 nike

我正在尝试将以下 2 条语句转换为 shell 脚本

cat all5.log | grep 'Opened\|Closed'> all.log
awk -F ' ' '{print }' all.log | sort | uniq > uniqueFiles.txt

这里是monitorFd.sh bash脚本

#!/bin/bash

if [ "" != "" ]; then
cat | grep 'Opened\|Closed' > temp.log
awk -F ' ' '{print }' temp.log | sort | uniq > uniqueFiles.txt

while IFS='' read -r line || [[ -n "$line" ]]; do
cmd1=`cat | grep Opened | grep $line | sort | wc -l`
cmd2=`cat | grep Closed | grep $line | sort | wc -l`
echo 'Opened: '$cmd1', Closed: '$cmd2' '$line
done < "uniqueFiles.txt"

rm -f temp.log
else
echo "No target file provided. (hint: trace dump of file-leak-detector.jar)" #syntax error: unexpected end of file

在 notepad++ 中,我将此文件更改为 UNIX 格式。还更改了对 +x 的权限,但我遇到了以下异常。

monitorFd.sh: line 16: syntax error: unexpected end of file

enter image description here

这个程序有什么问题?

最佳答案

bash 中 if 的语法是 if ... else/elif ... fi。所以只需在文件末尾添加 fi 即可。

关于linux - 需要帮助解决 "unexpected end of file"异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38432595/

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