linux - Bash Script: Test vs. if issues -
I am trying to write a simple script to check the current good level of a process.
Works without any problems:
test "$ (ps axl | grep '[m] y_process' | awk '{print $ 6}')" ! = '-10' & amp; Amp; (Echo test) However, I do more than just a simple echo and I hope that if it breaks into a statement. Being said, using the exact test, it fails every time. Here's the code:
if ["$ (ps axl | grep '[m] y_process' | awk '{print $ 6}')"! = '-10']; Then the "test" echo # # other stuff is going here As a result, I'm sure there is something wrong with my syntax - I also compare these and the good levels (eg, -10) Have tried to use double quotes.
Thanks in advance for help.
Edit to edit:
When I just try to run:
ps axl | grep '[m] y_process' | From a script awk '{print $ 6}' , it returns an empty string instead of the process, so I compressed it down ... < p> 2 was edited to add:
The test command was run from the console, so syntax can not work with a script ...
This is a frequently asked question if statement processes the exit status of UNIX commands, Commands include the test command, simply use the natural exhaust position of those commands that you do not have to try to test the string output of the expression inside test Trying to do For example: if ps axl | Awk '/ [m] y_process / {if ($ 6 ==-10) {exit 1} and {exit 0}}' one ?? |
Comments
Post a Comment