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
What the command to find out the record length of a fixed length file? tranq01 UNIX for Dummies Questions & Answers 9 12-04-2008 04:04 PM
length function ravi raj kumar UNIX for Advanced & Expert Users 3 08-03-2007 05:40 AM
Length of a Unix filepath max length wilsontan UNIX for Dummies Questions & Answers 3 02-22-2006 10:19 AM
Sed working on lines of small length and not large length thanuman UNIX for Dummies Questions & Answers 3 04-15-2005 07:12 AM
creating a fixed length output from a variable length input r1500 Shell Programming and Scripting 2 12-03-2003 01:09 PM

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-20-2007
silex's Avatar
silex silex is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 11
PID length

Does somebody know how many characters can have a PID as maximum?

I'm trying to get the PID of another process running in the same machine. I'm doing this:


Code:
ps -ef | grep "bin/Alime" | grep -v grep  | cut -c10-16

but I don't know if I 'll have enough with six chars. Which is the max value that it can take?

thanks in advance
  #2 (permalink)  
Old 12-20-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
that depends on the maximum number allowed for a PID and it varies from system to system
  #3 (permalink)  
Old 12-20-2007
silex's Avatar
silex silex is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 11
I'm looking for a PIDMAX or something like this, but I can't find anything. This is my system:

Code:
ASASTR:include> uname -a
OSF1 CLHASASTR V5.1 2650 alpha

Thanks again
  #4 (permalink)  
Old 12-20-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
cannot you just get the whole column instead of relying on character ranges?
something like:

Code:
ps -ef | grep '[b]in/Alime' | cut -d ' ' -f1

  #5 (permalink)  
Old 12-20-2007
silex's Avatar
silex silex is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 11
yes, the whole column would be great. I have tried to get only the second column


Code:
 ps -ef | grep "bin/Alime" | grep -v grep  | cut -f 2

but it shows the whole line again. I don't know why, maybe the command is not correct.

thanks
  #6 (permalink)  
Old 12-20-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131

Code:
ps -ef | grep '[b]in/Alime' | cut -d ' ' -f 2

cut's field delimiter is 'tab' by default......
  #7 (permalink)  
Old 12-20-2007
silex's Avatar
silex silex is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 11
these are my outputs:


Code:
ASASTR:clh> ps -ef | grep "bin/Alime" | grep -v grep
clh      221867 217065  0.0 11:34:01 pts/4        0:00.08 /usr/local/clh/ALPHA/oasys/bin/AlimentaLookAhead

ASASTR:clh> ps -ef | grep "bin/Alime" | grep -v grep  | cut -c10-16
221867

ASASTR:clh> ps -ef | grep "bin/Alime" | grep -v grep  | cut -d ' ' -f1
clh

ASASTR:clh>  ps -ef | grep "bin/Alime" | grep -v grep  | cut -d ' ' -f2

ASASTR:clh>  ps -ef | grep "bin/Alime" | grep -v grep  | cut -f2
clh      221867 217065  0.0 11:34:01 pts/4        0:00.08 /usr/local/clh/ALPHA/oasys/bin/AlimentaLookAhead

asking for the first column (-f1) i get the username, but asking for the second (-f2) i get the whole line.
Thanks.
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 06:18 PM.


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