![]() |
| Powered by phpBay Pro |

Linux: how to check a block of output for a single word?
Using shell script, I am invoking the compiling of several program files in Linux. When the script enters the line that begins compiling my program files, a buzz of lines and paragraphs is outputted indicating the status of the compiling. I would like to scan this entire passage for a single word. How do I do this in shell script?
You're looking for the "grep" command, plus you need to know how to pipe the output of one command into the input of another.
E.g., suppose you're using the "gcc" compiler, and you want to know if there are any errors in the compilation.
gcc program.c | grep error
The only output you will get from that command is any line that contains "error".
You may want some other caveats, such as:
gcc program.c | grep -i error
The "-i" option tells it to ignore case, so "ERROR", "Error" and "error" will all get captured.
You may want to use the "egrep" program, which is "Expression Grep"
gcc program.c | egrep -i "warning|error"
Now you'll see any "error" and you'll also see any "warning."
ALSO NOTE you may need to redirect "Standard Error" instead of "Standard Output". That is, what I've shown you assumes that "gcc" will send all the error messages to "stdout". If it sends those messages to "stderr" instead (which is very typical), you'll have to do something slightly different to pipe that output.
This will be left as an exercise for the student.
![]() |
![]() C band LNB BSC421 Single Output Low Noise Level US $1,438.40
|
![]() BK Precision Power Supply 1790 Single Output 32V 20A US $1,372.50
|
![]() Tango XE 20 600S Single End Output Transformers 6C33C Tubes US $1,190.00
|
![]() BK Precision 9123A Single Output DC Power Supply US $733.50
|
![]() Sea Gull Lighting 9378 98 Brushed Stainless Single Output Transformer US $720.00
|
![]() BK Precision 9124 Single Output DC Power Supply US $715.00
|
![]() Agilent HP 6038A Single Output Power Supply 001 220 US $444.00
|
![]() Agilent HP 6038A Single Output Power Supply with 001 US $444.00
|
![]() Agilent HP 6634A Single Output Power Supply US $439.00
|
![]() MASTECH 300W SINGLE OUTPUT BENCHTOP POWER SUPPLY US $299.95
|
![]() Surefire M6LT Guardian Extended Range Single Output LED US $298.00
|
![]() High output box stator and rotor single phase 200 watt US $287.00
|
![]() HACH AQUATREND SINGLE OUT PUT MODULE 51250 18 51350 18 INTERFACE MODULE US $265.00
|
![]() Derale 16817 Single High Output Electric RAD Fan with Aluminum Shroud US $250.98
|
| Powered by phpBay Pro |



US $5,999.99



















































































