Script showStreamsGLIS$reg.$env.ksh gives me output as below-
Job Stime Etime Status ExitCode
GLIS-AS-S-EFL-LOCK-B ----- ----- OI 103313880/0
GLIS-ALL-Q-EOD-FX-UPDT-1730-B ----- ----- TE 0/0
GLIS-TK-S-BWSOD-B ----- ----- OI 191344064/0
GLIS-TK-S-BWSODWAIT-B ----- ----- OI 191344064/0
GLIS-ALL-S-BWEC-B 10/06/2016 10:48:12 ----- RU 196982837/1
GLIS-ALL-S-BWEC-START-B 10/06/2016 10:48:13 ----- RU 196982837/1
GLIS-ALL-S-BWEC-GATHER 10/06/2016 10:48:16 ----- RU 196982837/1
GLIS-ALL-S-BWEC-BWPP-BAL-J ----- ----- OI 134547446/0
GLIS-ALL-S-BWEC-BWBM-BALS-J ----- ----- OI 134547446/0
GLIS-ALL-S-EOD-FX-UPDT-1730-B ----- ----- OI 0/0
GLIS-ALL-R-EOD-FX-UPDT-1730-B ----- ----- ST 0/0
GLIS-ALL-Q-EOD-FX-UPDT-1730-B ----- ----- TE 0/0
My requirement is to get rows containing status as 'OI/OH/RU' (highlighted few possible status values) and remove all trailing spaces. And I am trying to integrate this code in a perl script.
Idea is to do it without saving the output in a file.
I am using below and it is giving me error- egrep: write error: Broken pipe
my @pendJobs = `showStreamsGLIS$reg.$env.ksh | egrep ' OH | OI | RU ' | awk '{sub(/^ +/,X,$0);print}'`;
P.S: I am getting the output from a script and I don't want to use a file to temporary store the data and perform these activities. Trying to fetch the rows in a single command.
Without sample Input_file or without letting us know what you are trying to achieve, we all could guess only. So as a guess could you please try following and let us know how it goes then(seems you are using perl and didn't test it).
my @pendJobs = `showStreamsGLIS$reg.$env.ksh | awk '/OH|RU|OI/{sub(/^ +/,X,$0);print}'`;
So a important step of trouble shooting is either in any tool/code/operation is never neglect your error messages. So here we could see you script and then awk command is there, so it means there could be a chance your script itself is having issues, so following are the points:
Please try to run your script independently, is it running or not?
Post your script(if possible) or let us know what it does with complete details.
Check if you have used egrep command in script and try to figure out if that works or not?
Please follow above steps and additional too if you get any and let us know how it goes then.
Could you please go through following and let me know if this helps you.
awk '/OH|RU|OI/ ####So here we are searching for lines which have strings "OH" or "RU" or "OI", if yes then do following operations.
{sub(/^ +/,X,$0); ####Here I am using awk's built-in substitute functionality by using sub, whose syntax is--> sub(/pattern or value which needs to be substituted/,new_value,line/variable), so here
I am substituting each line which is starting with space by doing (^ ) with X(a variable) whose value is NULL in current line/record by mentioning $0.
print} ####printing line here, so either previous line's leading spaces were removed or not print will happen(as per your shown code only prepared it) in both the cases.
';