The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
reformat date, awk and sed mondrar Shell Programming and Scripting 5 06-05-2008 12:08 PM
help reformat data with awk climbak Shell Programming and Scripting 4 05-30-2008 11:17 AM
Date Reformat F-1 UNIX for Dummies Questions & Answers 2 04-25-2006 12:32 PM
reformat the file CamTu Shell Programming and Scripting 3 03-09-2005 02:01 PM
reformat the output from "diff" command CamTu Shell Programming and Scripting 5 03-01-2005 07:54 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-23-2008
Registered User
 

Join Date: Nov 2006
Posts: 54
reformat ps output

I often use "ps -ef" command to list all running processes. Now i want to customize the output to show only 2 parts: CMD and UID as below:

/bin/bash /usr/bin/run-parts /etc/cron.weekly root
/usr/sbin/httpd apache
/usr/sbin/httpd apache
/usr/sbin/httpd apache


I use
Code:
ps -ef | awk '{print $8" "$1}'
, but it's not a good way because CMD part can have its arguments (aka long list of options), we can not tell awk to do like this: awk '{print $8 $9 $10 $11 .... $20 " " $1}'.

Anyone know a better way in bash shell?
Thanks

Last edited by fongthai; 09-23-2008 at 12:53 AM. Reason: correct spelling
Reply With Quote
Forum Sponsor
  #2  
Old 09-23-2008
Registered User
 

Join Date: Sep 2008
Posts: 2
what are UNIX OS X Developer tools that are required to run Tomcat as daemon process.

Hi All,
can any one brief me about what are the UNIX OS X Developer tools that are required to run Tomcat as daemon process.

Problem : while Compiling JSVC it needs OS X Developer tools to be installed.

Reference :Installing Apache Tomcat 6 on Mac OS X 10.5 Leopard

can i use Mac Os x developer tools for unix os x developer tool ?
Reply With Quote
  #3  
Old 09-23-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
Code:
ps -eo command uid
the -o option allows you to specify which fields are output by ps. Consult your man page for ps for the exact format specifiers you want.
Reply With Quote
  #4  
Old 09-23-2008
Registered User
 

Join Date: Nov 2006
Posts: 54
hmm, -o is great, I can change to
Code:
ps -eo command,user
But if the command is long it'll be truncated.
Code:
ps -eo command:200,user
200 is a custom length for "command" can show, but we will face another issue: all commands will have a fixed length as 200 chars, the output will not clean to see. Anyway, thank you so much Jim!

Last edited by fongthai; 09-23-2008 at 02:25 AM. Reason: add code
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
awk reformat parse, format, ps -ef

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:27 PM.


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