- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk and special character
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2003 08:02 PM - last edited on 10-21-2012 10:04 PM by Maiko-I
03-16-2003 08:02 PM - last edited on 10-21-2012 10:04 PM by Maiko-I
Hi,
How can I get the list of processes which are not associated with any terminal device by using awk?( The processes with TTY column "?" when you execute ps -ef)
TIA.
-Suki
P.S. this thread has been moved from HP-UX > System Administration to HP-UX > languages - HP Forums moderator
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2003 08:12 PM
03-16-2003 08:12 PM
Re: awk and special character
# ps -ef | grep " ? "
NOTE: There are supposed to be 2 spaces between (before and after) the " characters and the ? character.
Please be careful when doing this though. There are a LOT of processes that are started by root when the system starts that have a ? in the tty column of 'ps' output. If you kill these you could potentially harm your system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2003 08:20 PM
03-16-2003 08:20 PM
Re: awk and special character
It sounds good but if there is a file named "abc ? cde" and somebody is using that file I will be in trouble when I run the script.
If we use awk and take the value of TTY column it will be accurate and I won't be in trouble.Can u please help me.
Thanks in Advance,
-Suki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2003 09:21 PM
03-16-2003 09:21 PM
Re: awk and special character
$ ps -e|sed 's/^[ \t]*//'|grep -v \^PID|awk '{print $2, $4}'|grep \^?
The sed statement removes leading spaces, the first grep filters out line starting with "PID" (ie the header), the awk prints the tty and the command and the last grep only shows line starting with "?".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2003 09:33 PM
03-16-2003 09:33 PM
Solutionhere is a snippet. does this help. (the if loops are to check if ? appears in the sizth coulumn (if the time is in hh:mm:ss format) or in the seventh column if the time is in mmm dd format)
ps -ef | awk '{ if ($5~/:/ && $6~/\?/ ) print; else if ($7~/\?/ ) print }'
hth
-balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2003 09:59 PM
03-16-2003 09:59 PM
Re: awk and special character
-Suki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2003 08:26 AM
03-18-2003 08:26 AM
Re: awk and special character
-dlt-