- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to grep a exactly string?
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
05-06-2003 12:32 AM
05-06-2003 12:32 AM
If I grep "ABC",
I will receive the result like follows:
ABC
ABCD
ABCDEF
If I only want the result "ABC" return, how does it do?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 12:34 AM
05-06-2003 12:34 AM
Re: how to grep a exactly string?
You can use : grep "ABC "
Franky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 12:38 AM
05-06-2003 12:38 AM
Re: how to grep a exactly string?
grep "ABC$"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 12:39 AM
05-06-2003 12:39 AM
Re: how to grep a exactly string?
It's not working!
ex:
#ps -ef|grep "ABC"
It will return all the line contain "ABC".
I want it return include "ABC" exactly.
Not "ABCD" or "ABCDEFR".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 12:42 AM
05-06-2003 12:42 AM
Re: how to grep a exactly string?
grep "ABC$" is not working too.
I can't find anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 12:47 AM
05-06-2003 12:47 AM
Re: how to grep a exactly string?
quite tricky. On 11.11 and onwards you can use the grep -w ABC for an exact match. On older versions you have to define something that makes it distinctive from the other possibilities, e.g.:
# grep ABC infile1 | grep -v "[D-Z]
but what can be used will depend on the situation.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 12:56 AM
05-06-2003 12:56 AM
Re: how to grep a exactly string?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 12:56 AM
05-06-2003 12:56 AM
Re: how to grep a exactly string?
Try this;
ps -ef|awk '{print $9}'|grep -x ABC
But this will only work if the command part of ps has ABC only on it - nothing else, not /bin/ABC or ABCD etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 12:56 AM
05-06-2003 12:56 AM
Re: how to grep a exactly string?
grep -w ABC
Regards.
Ernesto.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 01:12 AM
05-06-2003 01:12 AM
Re: how to grep a exactly string?
ABC
AABC
ABCC
ABC
CBA
ABCD
ABCDE
ABC DEF
FABC D
l1:/tmp 104 > perl -ne '/\bABC\b/ and print' xx
ABC
ABC
ABC DEF
l1:/tmp 105 >
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 01:22 AM
05-06-2003 01:22 AM
Re: how to grep a exactly string?
grep -x ABC
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 01:26 AM
05-06-2003 01:26 AM
Re: how to grep a exactly string?
As Ravi said, grep -x will do the trick.
from the man page
---
-x (eXact) Matches are recognized only when the
entire input line matches the fixed string or
regular expression.
---
Is this what you are looking for
HTH
Umapathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 01:51 AM
05-06-2003 01:51 AM
Re: how to grep a exactly string?
no "-w" function included.
I use "ps -ef" command and I want to grep the user name and the other information.
so I can't use the option "-x" to grep full line.
I try to use "awk" but only can find the user name . the other information was cut.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 02:11 AM
05-06-2003 02:11 AM
Re: how to grep a exactly string?
I've this grep version
(grep -V)
grep (GNU grep) 2.2
(Cygnus)
Copyright (C) 1988, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
and if i've 2 file "psgrep" and "psgreps"
# >ll | grep -w psgrep
-rwx------ 1 X users 276 Dec 17 10:55 psgrep
# >ll | grep psgrep
-rwx------ 1 X users 276 Dec 17 10:55 psgrep
-rwx------ 1 X users 276 May 6 10:44 psgreps
Regards.
Ernesto.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 02:24 AM
05-06-2003 02:24 AM
Solutiongives you all the processes of user 203
# ps -ef
gives you *all* processes
"And other information" is much to vague for us to solve
Attached is a perl script that mimics ps behaviour (without using 'ps') and runs on HP-UX and AIX. Easy to modify to get other fields or info
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 02:24 AM
05-06-2003 02:24 AM
Re: how to grep a exactly string?
Perhaps try it in another way ...
ps -fu login
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2003 02:31 AM
05-06-2003 02:31 AM
Re: how to grep a exactly string?
The best alternate is to try ps -fu ABC instead of ps and grep.
HTH
Umapathy