|
|||||||||
| Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here. |
unix and linux commands - unix shell scripting |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
that depends on the maximum number allowed for a PID and it varies from system to system
|
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
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
|
||||
|
||||
|
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 |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
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 |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Code:
ps -ef | grep '[b]in/Alime' | cut -d ' ' -f 2 cut's field delimiter is 'tab' by default...... |
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
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. |
| Sponsored Links | ||
|
|
![]() |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Flat file-make field length equal to header length | sonali.s.more | Shell Programming and Scripting | 5 | 03-28-2012 09:39 AM |
| 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 |
| 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 |
|
|