Sponsored Content
Top Forums Shell Programming and Scripting PS -EF | GREP JAVA Modification Post 302937412 by rbatte1 on Thursday 5th of March 2015 11:25:01 AM
Old 03-05-2015
I'm confused a little. perhaps some good practice will help you whilst I try to work out what you need.

If you change your command to be ps -ef | grep jav[a] then you will only get the header and any real java processes, i.e. your grep will be excluded. If you want just a few columns from that very wide output, consider the -o formatting flag for the command instead, perhaps something like this will meet your needs if you are sure that these is just one real java process:-
Code:
ps -e -o pid= -o comm= | grep jav[a] | read PID COMM


I hope that this helps,
Robin
 

We Also Found This Discussion For You

1. Shell Programming and Scripting

ps -ef | grep java | wc -l

Hi all i have a syntax , Can some one please give me a script 1, I need to check and execute the command. ps -ef | grep java | wc -l 5 Output should me 5 if not have to run the command: ps -ef | grep java the following java process... (11 Replies)
Discussion started by: suresh_krish
11 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 12:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy