HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk search wildcards
Operating System - HP-UX
1827452
Members
4105
Online
109965
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
Forums
Discussions
Discussions
Discussions
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
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
09-18-2001 06:50 AM
09-18-2001 06:50 AM
hi,
I've got an awk script thanks to help on the itrc that I'm still playing around with.
It's called as follows from within a script.
awk -f script.awk search=$2 filename
The first line of the awk script looks as follows.
$0 ~ "" search{GOTIT=1}
Now, I've discovered that I can have wildcards passed from the shell script command line as follows:
$2 = 20..
will report 2001 2002 2003 -- 2099 etc..
$2 = 20. will report 201 - 209
$2 = 20 will report 1020 1120 etc..
how can I specify that the $2 of 2 only lists 2 and not 2222 2000 200 192 92 etc...
Thanks,
Bill
I've got an awk script thanks to help on the itrc that I'm still playing around with.
It's called as follows from within a script.
awk -f script.awk search=$2 filename
The first line of the awk script looks as follows.
$0 ~ "
Now, I've discovered that I can have wildcards passed from the shell script command line as follows:
$2 = 20..
will report 2001 2002 2003 -- 2099 etc..
$2 = 20. will report 201 - 209
$2 = 20 will report 1020 1120 etc..
how can I specify that the $2 of 2 only lists 2 and not 2222 2000 200 192 92 etc...
Thanks,
Bill
It works for me (tm)
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2001 10:11 AM
09-18-2001 10:11 AM
Solution
you'll need to do something like this:
$2="^2 | 2$|( 2 )|^2$"
basically, match a 2 with a blank space before and after, at the beginning of a line, at the end of a line, or on a line by itself.
if your pattern, 2 in this case, is delimited by something other then a space or in addition to a space, maybe a tab, you'll need to modify as appropriate.
$2="^2 | 2$|( 2 )|^2$"
basically, match a 2 with a blank space before and after, at the beginning of a line, at the end of a line, or on a line by itself.
if your pattern, 2 in this case, is delimited by something other then a space or in addition to a space, maybe a tab, you'll need to modify as appropriate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2001 10:13 AM
09-18-2001 10:13 AM
Re: awk search wildcards
Hi Bill:
Pass a regular expression as:
# awk -f script.awk search=[^$2]$2[^$2] filename
In this case, only isolated character occurances equal to the character defined as $2, following the string "", will be printed from your script.
Regards!
...JRF...
Pass a regular expression as:
# awk -f script.awk search=[^$2]$2[^$2] filename
In this case, only isolated character occurances equal to the character defined as $2, following the string "
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2001 10:45 AM
09-18-2001 10:45 AM
Re: awk search wildcards
Hi (again) Bill:
Ten-points to Curtis! His solution handles the case where the matching single character occurs at the line's end (mine doesn't). Curtis' solution generalizes for the case where you want to match a single character at the beginning of a line too (mine doesn't).
Regards!
...JRF...
Ten-points to Curtis! His solution handles the case where the matching single character occurs at the line's end (mine doesn't). Curtis' solution generalizes for the case where you want to match a single character at the beginning of a line too (mine doesn't).
Regards!
...JRF...
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.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP