Unix Bourne Shell,输出混乱

时间:2018-04-05 21:44:16

标签: linux bash sh

编写一个shell脚本,显示文件中单词,字符,行的总数。假设文件名是作为命令行参数给出的。

我的代码

char= wc -c < test.txt
wrd= wc -w < test.txt
ln= wc -l <test.txt
echo "Number of characters in test.txt is $char" 
echo "Number of words in test.txt is $wrd"
echo "Number of lines in test.txt is $ln"

输出

20
3
3
Number of characters in test.txt is
Number of words in test.txt is
Number of lines in test.txt is

预期输出

Number of characters in test.txt is 20
Number of words in test.txt is 3
Number of lines in test.txt is 3

请帮忙。我是一个初学者,我已经尝试了很多方法来解决它,但我无法理解我哪里出错了。

0 个答案:

没有答案