The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 02-16-2007
Registered User
 

Join Date: Jan 2007
Posts: 22
cut question

Code:
#!/bin/bash

echo "UserName  PID     Command"
ps -ef > ps.temp
grep '^[a-z]\{2,3\}[0-9]\{4\}' ps.temp > ps.temp2
cut -f1,2,8 ps.temp2
rm ps.temp*
I am having some problems with the cut command. I only want to display the UID (field 1), PID(field 2), and Command(field 8). Right now the whole ps -ef line is display. Please help?!
Reply With Quote
Forum Sponsor
  #2  
Old 02-16-2007
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,590
Why don't you just use the formatted output ps command?

eg:
Code:
ps -eo uid,pid,args
Reply With Quote
  #3  
Old 02-16-2007
Registered User
 

Join Date: Jan 2007
Posts: 22
yea that does make more sense...thanks!
Reply With Quote
  #4  
Old 02-16-2007
Registered User
 

Join Date: Jan 2007
Posts: 22
the uid displays as the number and not the username...how do i get the username instead of the number?
Reply With Quote
  #5  
Old 02-16-2007
Registered User
 

Join Date: Jan 2007
Posts: 366
Quote:
Originally Posted by knc9233
the uid displays as the number and not the username...how do i get the username instead of the number?
you make me wonder what the use is of manual pages in Unix

ps -eo user,pid,args
Reply With Quote
  #6  
Old 02-16-2007
Registered User
 

Join Date: Feb 2005
Location: Broomfield, CO
Posts: 401
Now now

(2) No negative comments about others or impolite remarks. Be patient.

That's why for some of the questions that would be easily found, I'll post "man find" for example or "a google search found".



Carl
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0