当我做grep foo *
时,我收到了许多警告:
grep: dir1: Is a directory
grep: dir2: Is a directory
grep: dir3: Is a directory
grep: dir4: Is a directory
grep: dir5: Is a directory
我宁愿只看到结果而不是这些警告。
答案 0 :(得分:1)
grep foo * --directories=skip
将跳过像常规文件一样的grepping目录。
根据手册页:
-d action, --directories=action Specify the demanded action for directories. It is `read' by default, which means that the directories are read in the same manner as normal files. Other possible values are `skip' to silently ignore the directories, and `recurse' to read them recursively, which has the same effect as the -R and -r option.
此外,grep foo * -s
也会做同样令人满意的事情。
-s, --no-messages Silent mode. Nonexistent and unreadable files are ignored (i.e. their error messages are suppressed).