簡體   English   中英

Bash script eval output and grep the substring of the output to write conditions

[英]Bash script eval output and grep the substring of the output to write conditions

我在變量cmds中有一個命令。

在 bash 腳本$eval ${cmds[1]}上執行此命令后,它具有 output:

about to fork child process//
forked process: 1234
all output going to: /rand/direc/filename.log
child process started successfully, parent exiting.

我想在 bash 中寫一個條件,在那里我尋找“子進程已成功啟動”,並執行某些命令,

else echo -e "child process not started successfully"

Grep 字符串管道的執行命令通過到 tee /dev/tty 以將命令的 output 顯示到屏幕

if eval ${cmds[1]} | tee /dev/tty | grep -q "child process not started successfully"
then 
     echo "OK"
fi

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM