Results 1 to 10 of 10

Thread: search a word

  1. #1
    Join Date
    Dec 2002
    Posts
    104

    Unanswered: search a word

    Hello All,

    I wud like to know how can i grep a word in a file.
    For example : like to find 87 ....

    so result shud give me 87 ..not 1487 or 98771.

    Also, Please tell me a way to find out the completion of background processes.

    Any help wud be appreciated.

    thanx in advance

    --Pooja

  2. #2
    Join Date
    Jan 2004
    Posts
    51

    Re: search a word

    try using -w option
    e.g. grep -w 87 filename

    sushant

  3. #3
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: search a word

    Completion on background process ...

    pooja, Can you elaborate a bit on what you need

    Cheers
    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  4. #4
    Join Date
    Dec 2002
    Posts
    104

    Re: search a word

    Originally posted by sathyaram_s
    Completion on background process ...

    pooja, Can you elaborate a bit on what you need

    Cheers
    Sathyaram
    Hello Sathyaram,

    My requirement is, i am sending something for background processing and dependent on its completion i wud like to proceed further.

    At present what i am doing is , i am taking the process ids of background processes intiated in a file .Then using this command,

    var=ps -ef | egrep -c -f <file which contains process ids for background proceses>

    and checking till var != 0
    (I am sure there will be much better ways to do this.)

    Here i am facing a problem,

    egrep is doing a pattern searching , i want to find full word not the part of word.

    Also, if there is better way to do this , please tell me

    thanx in advance.

    --Pooja

  5. #5
    Join Date
    Dec 2002
    Posts
    104

    Re: search a word

    Originally posted by sushant
    try using -w option
    e.g. grep -w 87 filename

    sushant
    Hi sushant,

    thanx, its working

    --Pooja
    Last edited by pooja; 01-21-04 at 23:18.

  6. #6
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525

    Re: search a word

    Originally posted by pooja

    Also, Please tell me a way to find out the completion of background processes.
    Use the 'wait' command. You can give it a pid but it's esier to use the job id.

    e.g.

    sleep 5 &
    wait 1
    echo Done waiting

    HTH

  7. #7
    Join Date
    Dec 2002
    Posts
    104

    Re: search a word

    Originally posted by Damian Ibbotson
    Use the 'wait' command. You can give it a pid but it's esier to use the job id.

    e.g.

    sleep 5 &
    wait 1
    echo Done waiting

    HTH
    thanx

    but i am sending 10 jobs in background .Please advice .

    --Pooja

  8. #8
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525

    Re: search a word

    Originally posted by pooja

    but i am sending 10 jobs in background .Please advice .
    If you were to use 'wait' in this instance, I would suggest using the pid rather than the job id. Get the pid using ps + awk/sed/grep/cut (or whatever).

    That said, if it's going to get complicated, I would have each background process write to a file on completion and have a daemon/loop to check that file for the status of each background process before kicking off the next process.

  9. #9
    Join Date
    Dec 2002
    Posts
    104

    Re: search a word

    Originally posted by Damian Ibbotson
    If you were to use 'wait' in this instance, I would suggest using the pid rather than the job id. Get the pid using ps + awk/sed/grep/cut (or whatever).

    That said, if it's going to get complicated, I would have each background process write to a file on completion and have a daemon/loop to check that file for the status of each background process before kicking off the next process.
    thanx,

    at present what i am doing is, i am writing the PID into a file when i send a job in background and after sending all the required jobs in background i am checking the system if any PID exists there, for this i am using a while loop
    while var>0
    do
    var=ps-ef -o pid | grep -cw -f filewithpid
    wait 60
    done


    --Pooja

  10. #10
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    Hi Pooja.

    I'm not sure what the 'wait 60' is doing, I think you mean 'sleep 60'.

    The only problem I can see with how you have implemented your solution would be if one of your processes failed. The pid would no longer exist, so your dependent process would kick-off!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •