- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need to grep between a range
Operating System - HP-UX
1753767
Members
5477
Online
108799
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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-25-2009 05:06 PM
тАО03-25-2009 05:06 PM
I have following output from a wget command -
1238029403|tobc10|99
1238029403|tobc11|725
1238029403|tobc12|734
1238029403|tobc13|99
1238029403|tobc14|99
1238029403|tobc15|99
1238029403|tobc16|99
1238029403|tobc17|99
1238029403|tobc18|100
1238029403|tobc19|100
1238029403|tobc20|146
1238029403|tobc21|99
1238029403|tobc24|619
1238029403|tobc2|670
1238029403|tobc3|720
1238029403|tobc4|389
1238029403|tobc5|768
1238029403|tobc6|99
1238029403|tobc7|720
1238029403|tobc8|738
1238029403|tobc9|718
1238029403|tob|1384
And I need to grep for rows in which the value is less than 100.
Here is what I have been trying but doesnt work -
cat tmp|egrep 'tob [0-99]'
Please Help!
Thanks,
Allan
Solved! Go to Solution.
- Tags:
- grep
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2009 06:35 PM
тАО03-25-2009 06:35 PM
Solution
I assume you are talking about the third
column?
If so, here is one of the solutions:
awk -F"|" '$3 <= 99 {print}' tmp
I just tested it on my Fedora 10 server. Works fine. I am not at my desk at the moment so
I cannot check it on an HP-UX server.
Cheers,
VK2COT
column?
If so, here is one of the solutions:
awk -F"|" '$3 <= 99 {print}' tmp
I just tested it on my Fedora 10 server. Works fine. I am not at my desk at the moment so
I cannot check it on an HP-UX server.
Cheers,
VK2COT
VK2COT - Dusan Baljevic
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2009 06:58 PM
тАО03-25-2009 06:58 PM
Re: Need to grep between a range
Hmm, why 'cat' before 'grep'?
Grep will happily read a file on it's own.
With 'the value', do you mean the last column when treating a bar as a column seperator? Then what is the 'tob' doing in the search string?
In that case any value less than 100 which has 1 or 2 digits only, will have a | seperator 2 or 3 bytes from the end of line.
So try:
grep -e "|..$" -e "|.$" tmp
The expression [0-99] you presented translates to: a single character in the range 0 thru 9, or 9.
You MIGHT want:
grep -e "|[0-9][0-9]$" -e "|[0-9]$" tmp
Hope this helps,
Hein.
Grep will happily read a file on it's own.
With 'the value', do you mean the last column when treating a bar as a column seperator? Then what is the 'tob' doing in the search string?
In that case any value less than 100 which has 1 or 2 digits only, will have a | seperator 2 or 3 bytes from the end of line.
So try:
grep -e "|..$" -e "|.$" tmp
The expression [0-99] you presented translates to: a single character in the range 0 thru 9, or 9.
You MIGHT want:
grep -e "|[0-9][0-9]$" -e "|[0-9]$" tmp
Hope this helps,
Hein.
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2009 09:47 AM
тАО03-26-2009 09:47 AM
Re: Need to grep between a range
Thanks Folks
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP