1、CAT命令在用户主目录下创建一名为f1的文本文件,内容:Linux is useful for us all.You can never imagine how great it is。
2、向文件f1增加以下内容:Why not have a try?。
3、输入命令“wc
4、输入命令“cat countf1”,查看countf1文件的内容,其内容是f1文件的行数,和单词数及字符数信息。
5、即f1文件共有3行,19个单词和87的字符。
可以用 $? 获取上一条shell命令的返回结果。
一般的约定是: 0 表示成功,非0表示失败。
例如:你可以试验一下
执行正确的shell 命令: 执行 ls,然后紧接着 echo $?
执行错误的shell 命令: 执行 ls /abcdefg,然后紧接着 echo $?
findEXIT STATUS find exits with status 0 if all files are processed successfully, greater than 0 if errors occur. This is deliberately a very broad description, but if the return value is non-zero, you should not rely on the correctness of the results of find.换个思路撒:find "$path1" -maxdepth 1 -iname "$moduleName" | wc -l非零表示文件找到PS:参数加上双引号 查看更多答案>>