On Mon, 19 Jun 2006, Sebastien Roy wrote:
print $1 "\t" $2 "\t" $3 "\t" newlinks "\t" $5 "\t" $6 "\t" $7
{
gsub(/[^,]*/, "&/0", $4);
print;
}
Hmm, that has the strange side-effect of replacing all of the tabs
separating the fields with spaces (in all of $0). For example, the
input line:
1 L4 2 bge1,bge0 auto off short
turns into
1 L4 2 bge1/0,bge0/0 auto off short
Any idea why gsub() would do that?
Because it modified a field, hence the line. So awk has no choice but to
reconstitute $0 from the various fields, for which it uses OFS
(output field seperator).
Your original print line will work, as you're directly specifying the
field seperators, as would:
{
gsub(/[^,]*/, "&/0", $4);
origOFS = OFS;
OFS = "\t";
print;
}
If having tab (rather than space) always be the OFS suits you just fine,
then you don't need the above modification, just set OFS = "\t" in a
BEGIN action:
BEGIN {
OFS = "\t";
}
{
gsub(/[^,]*/, "&/0", $4);
print;
}
Hope this helps :)
regards,
--
Paul Jakma,
Network Approachability, KISS. Sun Microsystems, Dublin, Ireland.
http://opensolaris.org/os/project/quagga tel: EMEA x19190 / +353 1 819 9190
_______________________________________________
networking-discuss mailing list
[email protected]