这是我的第一个 Bash 脚本,如果这个问题是微不足道的,请原谅我。我需要计算指定目录 $HOME/.junk 中的文件数。我认为这很简单,并假设以下方法可行:
numfiles= find $HOME/.junk -type f | wc -l
echo "There are $numfiles files in the .junk directory."
在命令行输入find $HOME/.junk -type f | wc -l
完全符合我的预期,只需返回文件数。为什么在我的脚本中输入它时不起作用?在将选项传递给实用程序时,我是否遗漏了一些特殊符号?
非常感谢您的时间和帮助。