管道命令和xargs的区别

来源:互联网 发布:wlan未识别的网络win10 编辑:程序博客网 时间:2024/04/29 23:27

  • 管道命令和xargs的区别
  • 效果展示

管道命令和xargs的区别

  • 管道命令,是把管道前面命令的输出结果,作为管道后面命令的“输入”。
    个人理解,就当是把管道前面命令的输出结果,加上双引号,以字符串的形式,传递给管道后面命令。
    如下命令,最终执行的是cat "--help"
echo "--help" | cat
  • xargs, 是把管道前面命令的输出结果,作为管道后面命令的“参数”。
    如下命令,最终执行的是cat --help
echo "--help" | xargs cat

效果展示

qilei@AFAAW-704030720:~$ echo "--help" | cat--helpqilei@AFAAW-704030720:~$ echo "--help" | xargs catUsage: cat [OPTION]... [FILE]...Concatenate FILE(s), or standard input, to standard output.  -A, --show-all           equivalent to -vET  -b, --number-nonblank    number nonempty output lines, overrides -n  -e                       equivalent to -vE  -E, --show-ends          display $ at end of each line  -n, --number             number all output lines  -s, --squeeze-blank      suppress repeated empty output lines  -t                       equivalent to -vT  -T, --show-tabs          display TAB characters as ^I  -u                       (ignored)  -v, --show-nonprinting   use ^ and M- notation, except for LFD and TAB      --help     display this help and exit      --version  output version information and exitWith no FILE, or when FILE is -, read standard input.Examples:  cat f - g  Output f's contents, then standard input, then g's contents.  cat        Copy standard input to standard output.Report cat bugs to bug-coreutils@gnu.orgGNU coreutils home page: <http://www.gnu.org/software/coreutils/>General help using GNU software: <http://www.gnu.org/gethelp/>For complete documentation, run: info coreutils 'cat invocation'qilei@AFAAW-704030720:~$
0 0
原创粉丝点击