【问题标题】:unix shell script to print the words and no.of. words that starts with a vowel用于打印单词和编号的 unix shell 脚本。以元音开头的单词
【发布时间】:2023-03-25 16:20:01
【问题描述】:

编写一个 shell 脚本,该脚本接受文本文件的名称并查找以元音开头的句子数、单词数和单词数。 我已经尝试过以下代码。每次我尝试它都会显示错误

**enter code here
echo"Enter File Name:"
read file
lc=$(wc --lines $file)
wc=$(wc --words $file)
vow=$(grep -o -i" [^AEIOUaeiou]" | wc --words $file)
echo "Lines" $lc
echo "Words" $wc
echo "Vowels Words" $vow**

【问题讨论】:

  • 显示什么错误?

标签: shell unix


【解决方案1】:

这里:

echo "Enter File Name:"
read file
lc=$(cat "${file}"|wc -l)
wc=$(cat "${file}"|wc -w)
vow=$(cat "${file}"|grep -o " [AEIOUaeiou][^ ]\+ " |wc -l)
echo "Lines: $lc"
echo "Words: $wc"
echo "Vowels Words: $vow"

【讨论】:

    猜你喜欢
    • 2020-06-29
    • 1970-01-01
    • 1970-01-01
    • 2020-11-10
    • 1970-01-01
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 2012-10-01
    相关资源
    最近更新 更多