我想在两个文件中搜索多个字符串。如果在两个文件中都找到一个字符串,则做一些事情。如果只在一个文件中找到一个字符串,那么做另一件事。
我的命令是下一个:
####This is for the affirmative sentence in both files
if grep -qw "$users" "$file1" && grep -qw "$users" "$file2"; then
####This is for the affirmative sentence in only one file, and negative for the other one
if grep -qw "$users" "$file1" ! grep -qw "$users" "$file2"; then
Run Code Online (Sandbox Code Playgroud)
否定和肯定这些陈述的方式是否正确?pd 我正在使用 KSH 外壳。
先感谢您。