In terms of a solution for picking one (and only one) version of awk to use, the problem here is you're doing three checks that are un-related to each other, and (as you've found) if multiple awks are found then you can end up with undesirable behaviour or the 'wrong' awk being picked.
The best thing to do here I think would be to use an if/elif/else kind of decision process, so that based on your order of precedence you pick one (and only one) version of Awk at all times.
For instance, if your order of preferred awk implementations is:
gawk
nawk
awk
then the following code would ensure that one, and only one, was picked (and it would be the first one found, in order of precedence):
So even if your system has both gawk and nawk, it will always pick gawk and leave it at that.
Can anyone explain to me why the first line doesn't work and the second seems to work fine. I am trying to find all occurances of text within a certain column (col 13) that start with the character V, I suppose it sounds simple but I have tried using the following but don't really understand what... (2 Replies)
Hi all,
I can run the following script using nawk..However, I find that teh server dun support nawk.. May I know how to change teh script to use awk such that it will work? Very urgent.. thx!
nawk 'BEGIN {FS=OFS=","}
NR==FNR{arr=$2;next}
$0 !~ "Documentation"{print $0;next} ... (2 Replies)
i'm new to shell scripting and have a problem please help me
in the script i have a nawk block which has a variable count
nawk{
.
.
.
count=count+1
print count
}
now i want to access the value of the count variable outside the awk block,like..
s=`expr count / m`
(m is... (5 Replies)
Hi Guys,
i tried these two commands. First in awk and nawk.
The nawk command is running fine but the awk command is throwing error.
What is wrong with the awk command. There are lot of awk commands running fine in my system
d003:/usr/local/dsadm/dsprod>nawk 'NR = 1 {print " "$0}' a.txt
... (6 Replies)
Hi everyone,
i am new to unix , so i want to know what is the use of awk and nawk.
because in most of the place this cmds were used.
so, if anyone provied the basic idea of this cmds, it will be much helpfull for me . . ..
Thnks in Advance :) (9 Replies)
Hi Guys,
I am in need of some help; I have an xml message file which contains personal details as shown below:
, message=, message=, message=, message=, message=, message=
I want to use nawk to parse these xml messages but I am new to awk and nawk.
What I want is to get output... (7 Replies)
Hi Guys,
This is the Input:
<xn:MeContext id="XXX012">
<xn:ManagedElement id="1">
<xn:attributes>
<xn:userLabel>XXX012</xn:userLabel>
<xn:swVersion>R58E68</xn:swVersion>
</xn:attributes>
</xn:ManagedElement>
</xn:MeContext>... (4 Replies)
I have 10 scripts which use awk/nawk extensively.
I have to always change awk to nawk and nawk to awk when i deploy all my scripts to different types of servers as some support nawk while other support awk.
Can you propose a solution that without having to tweak my 10 scripts at several... (8 Replies)