1
$ cat png.ll
./packages/apps/Mms/res/mipmap-hdpi/ic_launcher_smsmms.png
./packages/apps/Mms/res/drawable-hdpi/messagebox_pressed_left.9.png
./packages/apps/Mms/res/drawable-hdpi/messagebox_pressed_right.9.png
./packages/apps/Mms/res/drawable-hdpi/messagebox_default_left.9.png
./packages/apps/Mms/res/drawable-hdpi/messagebox_default_right.9.png
./packages/apps/Mms/res/drawable-hdpi-finger/ic_contact_list_sim2.png
./packages/apps/Mms/res/drawable-hdpi-finger/ic_contact_list_sim1.png

$ cat png.lll
./packages/apps/Mms/res/drawable-hdpi-finger/ic_contact_list_sim2.png
./packages/apps/Mms/res/drawable-hdpi-finger/ic_contact_list_sim1.png

grep -Ff png.ll png.lll 的结果与 grep -Ff png.lll png.ll 的结果相同

$ grep -Ff png.ll png.lll
./packages/apps/Mms/res/drawable-hdpi-finger/ic_contact_list_sim2.png
./packages/apps/Mms/res/drawable-hdpi-finger/ic_contact_list_sim1.png

$ grep -Ff png.lll png.ll
./packages/apps/Mms/res/drawable-hdpi-finger/ic_contact_list_sim2.png
./packages/apps/Mms/res/drawable-hdpi-finger/ic_contact_list_sim1.png

但是 grep -vFf png.lll png.ll 的结果与 grep -vFf png.ll png.lll 的结果不同

$ grep -vFf png.lll png.ll
./packages/apps/Mms/res/mipmap-hdpi/ic_launcher_smsmms.png
./packages/apps/Mms/res/drawable-hdpi/messagebox_pressed_left.9.png
./packages/apps/Mms/res/drawable-hdpi/messagebox_pressed_right.9.png
./packages/apps/Mms/res/drawable-hdpi/messagebox_default_left.9.png
./packages/apps/Mms/res/drawable-hdpi/messagebox_default_right.9.png

$ grep -vFf png.ll png.lll

为什么?为什么最后一个 grep 没有给出任何输出?

4

1 回答 1

1

您正在运行四个不同的命令,它们返回的结果如下:

# Show me all lines in png.lll that are also in png.ll
grep -Ff png.ll png.lll

# Show me all lines in png.ll that are also in png.lll
grep -Ff png.lll png.ll

# Show me all lines in png.ll that are *not* in png.lll
grep -vFf png.lll png.ll

# Show me all lines in png.lll that are *not* in png.ll
grep -vFf png.ll png.lll

希望这可以解决问题

于 2013-11-06T00:39:53.317 回答