gpt4 book ai didi

linux - 这个命令在 shell linux 中起什么作用

转载 作者:太空宇宙 更新时间:2023-11-04 04:09:56 25 4
gpt4 key购买 nike

TMPFILE=/tmp/jboss_ps.$$
${PS} ${PS_OPTS} | \
grep ${JBOSS_HOME}/java | \
egrep -v " grep | \
tee | $0 " | ${AWK} '{print $NF " "}' | \
sort -u > ${TMPFILE} 2>/dev/null

我想知道上面代码中这一行的具体作用

egrep -v " grep | \
tee | $0 "

起初我以为该行正在搜索不包含这个确切字符串“grep |\tee | $0”的所有内容,但看起来egrep正在处理管道,那么这里管道的意义是什么,它意味着“OR”吗?从我的测试来看,似乎不是,但如果这意味着输出重定向,那么内部 grep 会得到什么?为什么也只有 tee ?

最佳答案

据我所知

egrep -v " grep | \
tee | $0 "

无非

egrep -v " grep | tee | $0 "

其中 \ 是 bash 中的延续字符。

egrepgrep -E

相同

-v 用于反向选择

tee 只是另一个字符串

so egrep -v "grep | tee | $0 " 确实找到了包含字符串 {java path} 的行,并且在此结果中,所有与条件 {either of grep OR tee OR $0 } 不匹配的行$0 是文件名,而不是“$0”,因为它使用双引号而不是单引号:)

"commands | $variables" 倾向于扩展变量并使用实用程序。

关于linux - 这个命令在 shell linux 中起什么作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19669935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com