質問

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

I want to know what this precise line is doing from the code above

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

At first i thought that that line is searching for everything that does not contain this exact string "grep | \ tee | $0" but it appears that egrep is processing the pipes, so what's the significance of the pipes here, does it mean OR ? From my test it appears that it's not, but if it means output redirection then what's the inner grep getting ? And why is tee alone too ?

役に立ちましたか?

解決

AFAIK

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

is nothing but

egrep -v " grep | tee | $0 "

where \ is the continuation character in bash.

egrep is same as grep -E

-v for inverted selection

tee just another string

so egrep -v " grep | tee | $0 " does find lines that have the string {java path} and within this results, all the lines that doesn't match the condition {either of grep OR tee OR $0 } where $0 is the filename not a '$0' because it uses DOUBLE QUOTES and not single quotes :)

" commands | $variables " has the tendency to expand the variables and use the utility.

他のヒント

The commands in the pipeline before the egrep command is probably something like ps -ef|grep .... The egrep -v (Option)line you asked about is simply omitting lines you don't want in the results, in this case the initial grep command issued by the script, any tee commands and lastly $0 which is the name of the this script being executed. egrep allows to enter multiple patterns enclosed in double quotes and separated by pipe symbol. Syntax egrep -[option or not] "patern1|patern2|patern..."

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top