我正在编写一个使用wc -m
/wc -c
来计算字符串中字母数量的程序。它计算字母,但增加了一个。这是我目前拥有的:
echo "enter a word"
read var1
echo $var1 | wc -c
Run Code Online (Sandbox Code Playgroud)
但是,当我输入单词时,它会成功执行某些操作,例如,如果我输入“test”,它将输出 5。
为什么要这样做,是否有解决方法?
我目前正在用 raspberry pi 编写一个程序,它可以让我查看文件内部并以彩色显示我输入的内容我想我需要做一些事情,--colour
但我不知道该怎么做 100%
这是我当前的代码。
#!/bin/bash
echo "Enter the name of the file to search within"
read file
echo "Enter what you would like to look for"
read search
Run Code Online (Sandbox Code Playgroud)
然后我希望 grep 行。感谢您提供任何意见!