shell - 用于打印单词和编号的 unix shell 脚本。以元音开头的单词
问题描述
编写一个 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**
解决方案
这里:
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"
推荐阅读
- git - 恢复推送的合并以删除错误推送的本地不需要的更改
- netlogo - 为什么 NetLogo 中的邻居补丁不以海龟位置为中心?另外,在邻居处设置“目标”时,为什么不互惠?
- docker - Docker Build 抛出错误-“Docker 输出被剪裁,日志限制达到 1MiB”
- grid-search - 为什么 GridSearchCV 中每个任务的时间在估计期间会增加?
- python - 在python 3中猜数字游戏
- python - MongoDB通过pymongo查询时间太慢,如何提高查询速度?
- google-cloud-platform - 如何在另一个大查询计划查询运行后立即运行一个大查询计划查询
- python - 如何将 tkcalendar 限制为仅选择某些工作日
- c++ - Ifstream没有在C ++中读取整个文本文件
- python - 为什么a中的值不受b变化的影响?