在研究另一个问题时,我遇到了一个命令,
locate something | xargs -I {} bash -c "if [ -d "{}" ]; then echo {}; fi"
Run Code Online (Sandbox Code Playgroud)
我想了解更多。所以我运行man xargs并得到以下输出:
XARGS(1) General Commands Manual XARGS(1)
NAME
xargs - build and execute command lines from standard input
SYNOPSIS
xargs [-0prtx] [-E eof-str] [-e[eof-str]] [--eof[=eof-str]] [--null]
[-d delimiter] [--delimiter delimiter] [-I replace-str] [-i[replace-
str]] [--replace[=replace-str]] [-l[max-lines]] [-L max-lines]
[--max-lines[=max-lines]] [-n max-args] [--max-args=max-args] [-s max-
chars] [--max-chars=max-chars] [-P max-procs] [--max-procs=max-procs]
[--interactive] [--verbose] [--exit] [--no-run-if-empty]
[--arg-file=file] [--show-limits] [--version] [--help] [command …Run Code Online (Sandbox Code Playgroud) m@m-VirtualBox:~$ man netstat | grep "-t"
grep: invalid option -- 't'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
Run Code Online (Sandbox Code Playgroud)
我不想将-t选项传递给grep. 相反,我想找到有关讨论的手册页的netstat行-tnetstat 选项的(如果有。
我认为将-t引号括起来就足以使grep解释为一种模式而不是一种选择,但我错了。
如何做我想做的事?