Views:
8,360
Votes: 2
Tags:
command-line
bash
scripts
Link:
🔍 See Original Answer on Ask Ubuntu ⧉ 🔗
URL:
https://askubuntu.com/q/1060425
Title:
Execute a script when the output of a command has a specific string
ID:
/2018/07/29/Execute-a-script-when-the-output-of-a-command-has-a-specific-string
Created:
July 29, 2018
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
I would use this:
[[ $(Command1) == 1234 ]] && Command2
- The
[[
and]]
tests if the condition inside is true &&
executesCommand2
if the condition tested true$(...)
executes command inside parenthesis and returns output (what was echoed insideCommand1
```
```