The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
comparing values of same variable coolkid Shell Programming and Scripting 2 05-27-2008 06:45 PM
Problem cutting & comparing values wilsontan Shell Programming and Scripting 6 02-09-2006 11:48 AM
comparing two decimal values in KSH nandinisagar Shell Programming and Scripting 4 11-15-2005 06:36 PM
shell script comparing files in a file raina_nalin Shell Programming and Scripting 4 06-21-2005 07:00 AM
comparing two float values kavitha Shell Programming and Scripting 2 04-03-2004 02:32 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-19-2007
marconi marconi is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 41
comparing PID values of 2 Files in shell Options

Hi,

There is a file having a list of running PIDs and another file having
a list of registered PIDs. How can we check if each value of running
PIDs are less or more than the registered PIDs i.e. comparing the
value of each PID in both the files.


Request you to pls give your inputs.


Thanks a lot in advance.
  #2 (permalink)  
Old 12-19-2007
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,795
This doesn't make a lot of sense to me. PID's change as processes create new children, end, etc.

try awk:

Code:
awk ' 
       if FILENAME=="regfile" {i++; arr[i]=$1}
       if FILENAME=="pidfile" { if (arr[$NR] > $1 { print $1, " is greater than ", arr[$NR]}
                                     if (arr[$NR] > $1 { print $1, " is less than ", arr[$NR]}
                                     if (arr[$NR] = $1 { print $1, " is  equal to ", arr[$NR]}

        } ' regfile pidfile

  #3 (permalink)  
Old 12-19-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by marconi View Post
How can we check if each value of running
PIDs are less or more than the registered PIDs i.e. comparing the
value of each PID in both the files.
Apart from equality, what do less and more tell you about pids? It tells me more about the scripter than anything truely useful about the pids.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On




All times are GMT -4. The time now is 11:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0