Grep not working of jobs


 
Thread Tools Search this Thread
Top Forums Programming Grep not working of jobs
# 1  
Old 11-26-2012
Grep not working of jobs

I am using csh.

Output of command jobs
[RTL]{145}>jobs
[1] + Running /home/alokg/nedit-5.5-Linux-x86/nedit .cshrc
[2] Running /home/alokg/nedit-5.5-Linux-x86/nedit build/irun_usb2.log
[3] Running /home/alokg/nedit-5.5-Linux-x86/nedit ...

But if we do

jobs| grep R

we get nothing.

It seems grep is unable to get any stream out of jobs

I had tried
jobs > a
which effects in redirecting the output of jobs to file a . Hence jobs is not directing output to STDERR in case of csh.

Last edited by alokgarg79; 11-26-2012 at 11:34 PM.. Reason: Forgot to mention the variant of shell used i.e csh
# 2  
Old 11-26-2012
Hi.

On the system I use, the bash builtin jobs writes to STDERR, so one would need (using your example):
Code:
jobs 2>&1 | grep R

See man bash for details.

Best wishes ... cheers, drl
# 3  
Old 11-26-2012
Thanks for the reply

I forget to mention that I am using csh.
In csh it seems that output of jobs is directed to STDOUT not STDERR
as
jobs > a is redirecting the outputs to file a
I donot need to do jobs >& a as needed for redirect STDERR

Hence, I am finding the behavior as starange
# 4  
Old 11-27-2012
csh is strange and I have no idea why anyone uses it.

You are wrong. jobs writes to standard error, and I'm not sure it's possible to direct standard error to standard output except for the purpose of writing to a file.

It's easy to see it's writing to standard error, as grep which reads from standard output, gets nothing to read:
Code:
[scott:~/scripts] % sleep 100 &
[1] 37754
[scott:~/scripts] % jobs
[1]  + Running                       sleep 100
[scott:~/scripts] % jobs | grep sleep
[scott:~/scripts] %


Last edited by Scott; 11-27-2012 at 03:21 AM.. Reason: fixed error, added info
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep the 'not running' jobs and will send the update in mail with its name(job)

my request is: i have to create a script , which will grep the 'not running' jobs and will send the update in mail with its name(job) Scenario: logged in to machine abc went to particular path: cd /a/b/c then ./script1.sh status (script.sh is a script,whose status gives info about 10 jobs... (1 Reply)
Discussion started by: learner987
1 Replies

2. Shell Programming and Scripting

Shell script to run multiple jobs and it's dependent jobs

I have multiple jobs and each job dependent on other job. Each Job generates a log and If job completed successfully log file end's with JOB ENDED SUCCESSFULLY message and if it failed then it will end with JOB ENDED with FAILURE. I need an help how to start. Attaching the JOB dependency... (3 Replies)
Discussion started by: santoshkumarkal
3 Replies

3. Shell Programming and Scripting

Grep not working on mac

Hi all, I got a new mac and can't get grep, awk etc to work. I tried the following command: grep DICER test.txt output: AGOER text.txt looks like this: DICER DICER AGOWhat is wrong? Please use code tags (23 Replies)
Discussion started by: Palgrave
23 Replies

4. Shell Programming and Scripting

Working with grep-output

Hi, 1st post Sorry for borrowing the thread. Hopefully this is doable. I need to write a script where I need to pick information from my grep-results. grep -n "s_" file | head -n 1 Output is like this: 6:s_9: 11-664 Fam_g442_99 So this gives me the first line of the file which... (2 Replies)
Discussion started by: Shell_y
2 Replies

5. Shell Programming and Scripting

waiting on jobs in bash, allowing limited parallel jobs at one time, and then for all to finish

Hello, I am running GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu). I have a specific question pertaining to waiting on jobs run in sub-shells, based on the max number of parallel processes I want to allow, and then wait... (1 Reply)
Discussion started by: srao
1 Replies

6. UNIX for Dummies Questions & Answers

grep -f not working

Hello, I'm going crazy about this. I'm using grep to filter some values as in pas -ef | grep asterisk. When I use the same with -f somefile something weird happens, if somefile is created with vi it'll work, if somefile is created with vi but values are pasted from an Excell file it will not work.... (2 Replies)
Discussion started by: seveman
2 Replies

7. Shell Programming and Scripting

grep not working ????

Hi, I've prob in doing grep. I want to grep line staring with number 531250 in the 1st column from a file (example in picture attached below) using command grep -w "531250" file my ideal result should be 531250 1 21 42.1 100 1e-05 ... (8 Replies)
Discussion started by: masterpiece
8 Replies

8. UNIX for Dummies Questions & Answers

grep not working

This condition is not able to grep , can any one tell what's wrong with this part. I am able to see from unix command but not with host script. echo "Checking for Loader Status " >> $REPFILE if test $? = 0 then echo "Successful termination of SQL*Loader "$LOADER1 >>... (5 Replies)
Discussion started by: u263066
5 Replies

9. UNIX for Advanced & Expert Users

cat and grep not working

I am trying to cat a file and then grep that file for a number. I can do it fine on other files but this particular file will not do anything. I tried running it on an older file from the same device but it is just not working. The file is nothing more than a flat file on a unix box. Here is just a... (3 Replies)
Discussion started by: jphess
3 Replies

10. Shell Programming and Scripting

background jobs exit status and limit the number of jobs to run

i need to execute 5 jobs at a time in background and need to get the exit status of all the jobs i wrote small script below , i'm not sure this is right way to do it.any ideas please help. $cat run_job.ksh #!/usr/bin/ksh #################################### typeset -u SCHEMA_NAME=$1 ... (1 Reply)
Discussion started by: GrepMe
1 Replies
Login or Register to Ask a Question