Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
google site



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-28-2009
Registered User
 

Join Date: Dec 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Grep or Awk from a non-terminating program

Hey all,

Does anybody know how to grep or awk from a non-terminating program. For example the program top which displays the process cpu usage, idle %,...etc. I was wondering if I can grep or awk certain fields from it.
The other thing I was wondering about is how to insert a CTRL-C command in a shell script, is it possible??

Thanks in advance
Sponsored Links
  #2  
Old 12-28-2009
radoulov's Avatar
--
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 3,619
Thanks: 15
Thanked 55 Times in 54 Posts
Quote:
Originally Posted by ibrahimelkadi View Post
Hey all,

Does anybody know how to grep or awk from a non-terminating program. For example the program top which displays the process cpu usage, idle %,...etc. I was wondering if I can grep or awk certain fields from it.
Yes,
you can. Just send the input to the awk interpreter.

Quote:
The other thing I was wondering about is how to insert a CTRL-C command in a shell script, is it possible??
You can run top in batch mode (so you don't need to send it Ctrl+C) On Linux it would be something like this:


Code:
top -bn10 | awk ...

Check your top implementation's man pages for the exact command on your system.
  #3  
Old 12-28-2009
Registered User
 

Join Date: Dec 2009
Posts: 660
Thanks: 6
Thanked 49 Times in 47 Posts
Quote:
Originally Posted by ibrahimelkadi View Post
The other thing I was wondering about is how to insert a CTRL-C command in a shell script, is it possible??

Code:
kill -INT pid

If for some reason the script is sending ^C (SIGINT) to itself, then "$$" can be used as the pid.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can i terminating expect script without terminating SSH connection. fozay Shell Programming and Scripting 2 07-14-2009 01:25 AM
Terminating Processes by Name love833 HP-UX 1 02-12-2008 08:49 AM
Terminating child script with terminating the parent script mervin2006 UNIX for Dummies Questions & Answers 2 05-02-2007 07:54 AM
grep within ksh program cin2000 Shell Programming and Scripting 3 02-22-2006 09:55 AM
Terminating myself SeeD UNIX for Dummies Questions & Answers 2 04-13-2004 05:35 AM



All times are GMT -4. The time now is 07:31 AM.