第 43 行:语法错误:意外的文件结尾

发布于 2024-12-09 05:48:15 字数 828 浏览 0 评论 0原文

编译 unix 脚本代码时,我在第 43 行遇到语法错误。此代码用于搜索文本文件的文件夹并匹配 input.txt 中的任何单词。 不过代码还没有完成

#!/bin/bash

findkeyword () {
    file="$1"   
    keyword="$2"    
    value="$3"
    int count = 0
    cat $file | awk '{
    while read line
        do
            for (ii=1;ii<=NF;ii++) {
                if ($ii == $keyword)
                    count++
            fi
            }
        done
    }'
    echo "Profile: " $file
    scorefile $value $count

scorefile () {
    value="$1"
    count="$2"

    echo "Score: " $value*$count

}

cat input.txt | awk '{
    while read line
        do
            keyword=$1
            value=$2

            for xx in `ls submissions/*`
            do
                filename=$xx
                findkeyword $filename $keyword $value
            done
        done
}'

I am getting a syntax error on line 43 when compiling the unix script code. This code is to search through a folder of textfile and match any word from the input.txt.
code still hasn't finish yet though

#!/bin/bash

findkeyword () {
    file="$1"   
    keyword="$2"    
    value="$3"
    int count = 0
    cat $file | awk '{
    while read line
        do
            for (ii=1;ii<=NF;ii++) {
                if ($ii == $keyword)
                    count++
            fi
            }
        done
    }'
    echo "Profile: " $file
    scorefile $value $count

scorefile () {
    value="$1"
    count="$2"

    echo "Score: " $value*$count

}

cat input.txt | awk '{
    while read line
        do
            keyword=$1
            value=$2

            for xx in `ls submissions/*`
            do
                filename=$xx
                findkeyword $filename $keyword $value
            done
        done
}'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光倒影 2024-12-16 05:48:15
#!/bin/bash

findkeyword () {
  file="$1"   
  keyword="$2"    
  value="$3"
  int count = 0
  while read line; do
    for word in $line; do
        if [[ $word =  $keyword ]]; then
            $((count++))
        fi
    done
    done <$file
  echo "Profile: " $file
  scorefile $value $count
} # missing closing brace here

scorefile () {
  value="$1"
  count="$2"

  echo "Score: " $(($value*$count)) # Math evaluation broken

}

while read line
    do
        keyword=$1
        value=$2

        for xx in `ls submissions/*`
        do
            filename=$xx
            findkeyword $filename $keyword $value
        done
    done<input.txt
#!/bin/bash

findkeyword () {
  file="$1"   
  keyword="$2"    
  value="$3"
  int count = 0
  while read line; do
    for word in $line; do
        if [[ $word =  $keyword ]]; then
            $((count++))
        fi
    done
    done <$file
  echo "Profile: " $file
  scorefile $value $count
} # missing closing brace here

scorefile () {
  value="$1"
  count="$2"

  echo "Score: " $(($value*$count)) # Math evaluation broken

}

while read line
    do
        keyword=$1
        value=$2

        for xx in `ls submissions/*`
        do
            filename=$xx
            findkeyword $filename $keyword $value
        done
    done<input.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文