Re: simple awk question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 20, 2003 at 04:09:55PM -0500, Chuck Campbell wrote:
> On Mon, Oct 20, 2003 at 11:17:58AM +0300, urgrue wrote:
> > how can i print all BUT the last field. ie something like:
> > echo one.two.three.four | awk -F "." '{print <all from $1 to $(NF-1)>}'
> > =one.two.three
> 
> Sorry, I didn't test my first one.  Your syntax for calling awk was wrong,
> and I blindly copied it when I put in my recipe.   
> 
> This:
> echo one.two.three.four | awk -F "." \
>  '{for (i=1; i<NF-1 ;i++) {printf("%s.",$i)};printf("%s\n",$(NF-1))}'
> 
> Should actually read:
> echo one.two.three.four | awk -F. \
>  '{for (i=1; i<NF-1 ;i++) {printf("%s.",$i)};printf("%s\n",$(NF-1))}'
> 
> 
> Please note the -F flag difference in the awk command line.


It appears I was right, wrong and right again.  The original posting works
on all variants of gawk (gnu awk) and nawk I have available.

The second posting is required if you happen to be on Solaris, and are using
normal awk, however both work fine on Solaris using gawk or nawk.

Thanks to those who pointed out my error(s).

-chuck


-- 
ACCEL Services, Inc.| Specialists in Gravity, Magnetics |  1(713)993-0671 ph.
 2401 Fountain View |   and Integrated Interpretation   |  1(713)993-0608 fax
     Suite 320      |                                   |
 Houston, TX, 77057 |          Chuck Campbell           | campbell@xxxxxxxxxxxx
                    |  President & Senior Geoscientist  |

     "Integration means more than having all the maps at the same scale!"
-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux