Operating System - HP-UX
1748145 Members
3664 Online
108758 Solutions
New Discussion

awk difference (RE) between HP-UX and Linux

 
SOLVED
Go to solution
support_billa
Valued Contributor

Re: awk difference (RE) between HP-UX and Linux

Hello Dennis ,

thank you very much about your useful and helpful informations

>Do you have an example where it fails?
>but the options of ERE of gawk isn't possible to use for awk HPUX like r{n,m}  with possix

when you try to use HPUX awk and LINUX awk / HPUX gawk, then you get syntax errors !

> No, this is a bogus ERE, in that it most likely won't do anything useful.

so it works, but i have no guarantee that this ERE will work in the future , right ?

>You can see this if you change awk to add:
>BEGIN { print "ERE:", (+DB_TOKEN) }

i tested it , thank.

my last question ( i spoke with other colleagues ) :

is better to use "perl" with "ERE" for different plattforms ?

regards

Dennis Handly
Acclaimed Contributor

Re: awk difference (RE) between HP-UX and Linux

>when you try to use HP-UX awk and LINUX awk / HP-UX gawk, then you get syntax errors!

 

Do you have an example of that?


>so it works, but I have no guarantee that this ERE will work in the future, right?

 

No, it doesn't really work.  Your ERE is bogus.  A leading "+" doesn't make sense for a ERE.

 

>is better to use "perl" with "ERE" for different platforms?

 

In this case, if you have valid ERE, it should work in both cases.

But you may have a valid point, perl may be more portable and doesn't have the HP-UX awk limitations.

And matching has more choices.

support_billa
Valued Contributor

Re: awk difference (RE) between HP-UX and Linux

you will get examples next week

 

regards

support_billa
Valued Contributor

Re: awk difference (RE) between HP-UX and Linux

hello,

here my solution of perl ( instead of awk ) :

 

DB_TOKEN=DB_DEF perl -lan -F"#" -e'if($F[0] =~ /^\S+$ENV{DB_TOKEN}/) {print "$F[1] $F[4]"}' file

or

perl -F"#" -lane '$s=shift @F;if($s=~ /^\S+'$DB_TOKEN'/) {print "@F"}' file

 

with a little help of perl examples

regards