- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: use multiple field seperators with awk
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
тАО05-19-2005 09:36 PM
тАО05-19-2005 09:36 PM
use multiple field seperators with awk
In a testcase, my /etc/oratab looks like this:
# Oracle 8 stuff (ocho)
tst1:/mnt/u01/app/oracle/product/8.1.7:Y
# Oracle 9 stuff (el nino)
tst2:/mnt/u01/app/oracle/product/9.2.0:Y
tst3:/mnt/u01/app/oracle/product/9.2.0:N
for a backup script I need all "active" Oracle 9i databases. I came up with this:
DBLIST=$(awk -F: '$1 !~ /^#/ && $3 ~ /Y$/ {print $1}' ${ORATAB})
, but that does only filter the "Y" and comment lines. How can I filter the "9" (and 10 later on) out of the lines?
Best would be use something with >8
I'm struggling with split, but I'm stuck
Any ideas?
Cheerio,
Renarios
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2005 10:01 PM
тАО05-19-2005 10:01 PM
Re: use multiple field seperators with awk
I just did what you have said....
[rx260-11]/sudhi >cat kk
# Oracle 8 stuff (ocho)
tst1:/mnt/u01/app/oracle/product/8.1.7:Y
# Oracle 9 stuff (el nino)
tst2:/mnt/u01/app/oracle/product/9.2.0:Y
tst3:/mnt/u01/app/oracle/product/9.2.0:N
[rx260-11]/sudhi >awk -F: '$1 !~ /^#/ && $3 ~ /Y$/ {print $1}' kk
tst1
tst2
[rx260-11]/sudhi >
and see only test1,test2 in the o/p
what you want to achive? am I missing something in your question?
Sudeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2005 11:01 PM
тАО05-19-2005 11:01 PM
Re: use multiple field seperators with awk
Thanks for the quick response.
The output should be only tst2, because tst1 is 8.1.7 and I only want the active 9.2.0 (or in future higher) databases.
thanks,
Ren├Г
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2005 12:18 AM
тАО05-20-2005 12:18 AM
Re: use multiple field seperators with awk
awk -F: '$1 !~ /^#/ && $3 ~ /Y$/ && split($0, arr, "/") {if ( arr[7] > 8 ) print arr[7] "*" $1 " " $2 " " $3}' ${ORATAB}
, but it does not work.
Has anyone other/ideas ideas?
Cheers,
Renarios
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2005 12:43 AM
тАО05-20-2005 12:43 AM
Re: use multiple field seperators with awk
awk -F: '$1 !~ /^#/ && $3 ~ /Y$/ && split($0, arr, "/") && split(arr[7], oraver, ".") {if ( oraver[1] >= 9 ) print $1}' ${ORATAB}
10 point for Renarios?
Only thing is: How do I get this readable?
If I use BEGIN and END, it doesn't work anymore.
Anyone ideas?
Cheerio,
Renarios
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2005 12:51 AM
тАО05-20-2005 12:51 AM
Re: use multiple field seperators with awk
Because when you try to rewrite things so they'll look simplier, you can put there some bugs.
Good comment on this line will be enough I think :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2005 02:18 AM
тАО05-20-2005 02:18 AM
Re: use multiple field seperators with awk
awk -F: '$1 !~ /^#/ && $3 ~ /Y$/ {
split($0, arr, "/");
split(arr[7], oraver, ".");
if ( oraver[1] >= 9 ) print $1;
}' ${ORATAB}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2005 02:24 AM
тАО05-20-2005 02:24 AM
Re: use multiple field seperators with awk
That should do the trick.
Time for weekend. Have one on me.
Solution:
DBLIST=$( awk -F: '$1 !~ /^#/ && $3 ~ /Y$/ {
split($0, arr, "/");
split(arr[7], oraver, ".");
if ( oraver[1] >= 9 ) print $1;
}' ${ORATAB} )
Cheerio,
Renarios