- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: need to pass in variable as regular expression...
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
Discussions
Discussions
Forums
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
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
тАО10-23-2004 02:48 AM
тАО10-23-2004 02:48 AM
need to pass in variable as regular expression in awk
I have a line read from a file and I am trying to use that line as an expression in awk. It breaks down like this:
cat locks.tmp | while read LINE
do
awk '/spid/{x=1;y=0}/$LINE/ {if (y>3){l[y]="\n"; while(i++
I have tried using -v line=$LINE and then /.../.../line/ but it's not working...
The line looks like :
TYES Lock => Oct 23, 2004 00:14:45 - te_tyesp04_20 - 64
Anyone have any ideas???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2004 03:22 AM
тАО10-23-2004 03:22 AM
Re: need to pass in variable as regular expression in awk
/'$LINE'
IMHO - this would be better in perl - but I'm far from a perl guru - maybe Merijn can help you out :)
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2004 03:23 AM
тАО10-23-2004 03:23 AM
Re: need to pass in variable as regular expression in awk
awk '/...... / '$LINE.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2004 03:29 AM
тАО10-23-2004 03:29 AM
Re: need to pass in variable as regular expression in awk
/\\/'$LINE$'\\//
I think it's just a matter of finding the right number of escapes...
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2004 03:35 AM
тАО10-23-2004 03:35 AM
Re: need to pass in variable as regular expression in awk
awk -v line="TYES Lock => Oct 23, 2004 10:12:57 - te_tyesp05_25 - 146" '/spid/{x=1;y=0}/line/ {if (y>3){l[y]="\n"; while(i++
using it with -v doesn't work but if I don't use the -v...
awk '/spid/{x=1;y=0}/TYES Lock => Oct 23, 2004 10:12:57 - te_tyesp05_25 - 146" '/spid/{x=1;y=0}/line/ {if (y>3){l[y]="\n"; while(i++
I get what I'm looking for...
I just need a way to use the $LINE variable in my regular expression....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2004 04:02 AM
тАО10-23-2004 04:02 AM
Re: need to pass in variable as regular expression in awk
awk '/spid/{x=1;y=0}/TYES Lock => Oct 23, 2004 10:12:57 - te_tyesp05_25 - 146/ {if (y>3){l[y]="\n"; while(i++
It also doesn't like it if I put the actual LINE in quotes...
awk '/spid/{x=1;y=0}/"TYES Lock => Oct 23, 2004 10:12:57 - te_tyesp05_25 - 146"/ {if (y>3){l[y]="\n"; while(i++
Wonder why the line variable doesn't work??