- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: grep help
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
12-11-2003 03:55 AM
12-11-2003 03:55 AM
grep help
This line will also exclude any name with strings of xyz, for instance, will exclude "defxyz". However, I want to exclude exactly "xyz" only, not "defxyz", Can I do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 03:58 AM
12-11-2003 03:58 AM
Re: grep help
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 04:00 AM
12-11-2003 04:00 AM
Re: grep help
Will solve your problem.
-Karthik S S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 04:50 AM
12-11-2003 04:50 AM
Re: grep help
is xyz, which you want to exclude the only item in the line? If so use:
grep -v -E 'abc|^xyz$' filename
otherwise try:
grep -v 'abc' filename | grep [a-z,A-Z]xyz[a-z,A-Z]
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 05:02 AM
12-11-2003 05:02 AM
Re: grep help
if I am not mistaken then
grep -v -E 'abc|xyz' fielname
and
grep -v 'abc' fielname|grep -v 'xyz'
is the same
not (a or b) <=> not a and not b
or have I missed something?
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 05:02 AM
12-11-2003 05:02 AM
Re: grep help
grep -E 'abc|\
-Karthik S S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 05:04 AM
12-11-2003 05:04 AM
Re: grep help
Forgot "-v" in the above posting. No points for this ;-)
-Karthik S S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 05:20 AM
12-11-2003 05:20 AM
Re: grep help
Have you tried:
grep -v -E 'abc|^xyz$' filename
The ^ means: starts with xyz
and $ means : ends with xyz
So ^xyz$ means : begins and also ends with xyz witch is in common language: it must be exact xyz.
Greetzzz,
Kl@@s
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 05:35 AM
12-11-2003 05:35 AM
Re: grep help
I thought in similar lines too. Then I realized what he needs is to exclude a exact word whether it is in the start or mid or end of a line. So the best bet is \
I hope Hanry will be kind enough to encourage our new meber by assigning some points ....
-Karthik S S
No points for this Please ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 05:36 AM
12-11-2003 05:36 AM
Re: grep help
I think it is almost impossible, as you have to define the surroundings for "xyz" that need to be exluded, e.g. spaces around the string, the string alone on a line, string at beginning of a line followed by space, a digit in front of the string etc.
An idiotic example of some of these:
# grep -v -E 'abc|[[:space:]]xyz[[:space:]]|^xyz$|^xyz[[:space:]]|[[:digit:]]xyz$|xyz[[:digit:]]' ./infile
where infile holds these lines:
abc
xyz
xyz def
xyz 123
xyz123
123xyz
defxyz
What you probably do not want is to search positively for a string, but I think that would be easier.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 05:44 AM
12-11-2003 05:44 AM
Re: grep help
xyz def
xyz 123
xyz123
should all start with a space.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 05:44 AM
12-11-2003 05:44 AM
Re: grep help
please define what exactly it is, you do not want to be excluded!
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 08:45 AM
12-11-2003 08:45 AM
Re: grep help
The line I have now grep -v -E 'abc|xyz' filename, will exclude all lines with strings including "abc", "xyz", ex, it will exclude "ertabc", "afxyzsdf", that is not what I want. I want to exlude lines including "abc", or "xyz", or...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 08:58 AM
12-11-2003 08:58 AM
Re: grep help
grep -v -E '\
-Karthik S S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 10:49 AM
12-11-2003 10:49 AM
Re: grep help
THE LINE YOU SUGGESTED WOULD ALSO EXCLUDE "xyz" itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 10:59 AM
12-11-2003 10:59 AM
Re: grep help
grep -v abc | grep -v xyz | grep -v ...
It seems not very intelegency, but only one working.
'^xyz' not working is because the string is not located in the begining of the line, but in a field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 11:09 AM
12-11-2003 11:09 AM
Re: grep help
As per your first post you wanted to exclude ONLY xyz and your later statement conflicts that ???
-Karthik S S
Hanry:
This line will also exclude any name with strings of xyz, for instance, will exclude "defxyz". However, I want to exclude exactly "xyz" only, not "defxyz", Can I do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 11:31 AM
12-11-2003 11:31 AM
Re: grep help
I have a file with follwoing format:
...
f1|f2|abc |f4|f5...|
f11|f22|frontxyz |f44|f55...|
f111|f222|xyzend |f444|f555..|
..
f1111|f2222|frontxyzend |f4444|f55555..|
...
f11111|f2222|..... | ....
I want to list all fields contain ONLY "abc", "xyz", "this"...a certain string?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 11:34 AM
12-11-2003 11:34 AM
Re: grep help
I want to EXCLUDE those with only "abc", "xyz", "this"... a few certain strings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 12:00 PM
12-11-2003 12:00 PM
Re: grep help
Hanry -
Do I understand you to want the line but exclude a field within that line that contains the strings you mention?
Regards,
dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 12:11 PM
12-11-2003 12:11 PM
Re: grep help
sed s/xyz//g filename | sed s/abc//g | sed s/somestring//g
-Karthik S S
Hanry, did you read the first line of the Dave's post??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2003 08:40 PM
12-11-2003 08:40 PM
Re: grep help
attached is an awk script.
call awk -F"\|" awkscript yourfile
thats hopefully all you need,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2003 06:00 PM
12-12-2003 06:00 PM
Re: grep help
I also got the similar requirement......i.e. I want to avoid all the lines containing the word "mathi" & not "mathivanan" or "abcmathitest" from my i/p file.....my sample i/p files looks as follows:
-------------------------------
1 mathi a bcdtest
2xyz mathivanan hopeso
3 hanry
4karthik s s mathi
5 Michael Schulte mathiabc
6 Pete Randall testmathi
7Klaas D. Eenkhoorn mathi
8john korterman aa mathi
9 Dave La Mar smathia
-------------------------------
I want the ouput after avoiding the lines containing exactly the word "mathi".....which'll be as follows:
-------------------------------
2xyz mathivanan hopeso
3 hanry
5 Michael Schulte mathiabc
6 Pete Randall testmathi
7Klaas D. Eenkhoorn mathi
9 Dave La Mar smathia
-------------------------------
I hope I made my requirement very clear......I want to know how i can get this by way of "grep" or any script which'll do this job for me......
Thanks in advance.....
Regards,
karthik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2003 09:44 PM
12-12-2003 09:44 PM
Re: grep help
would you please open a new thread for this? You get better attention and are able to award points for the help given.
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2003 10:42 PM
12-12-2003 10:42 PM
Re: grep help
I've posted as a new topic.....thanks for correcting my fault....
regards,
karthik