From: Chuck Campbell <campbell@accelinc.com>
To: urgrue <urgrue@tumsan.fi>
Cc: admin <linux-admin@vger.kernel.org>
Subject: Re: simple awk question
Date: Mon, 20 Oct 2003 16:09:55 -0500 [thread overview]
Message-ID: <20031020210955.GA14839@helium.inexs.com> (raw)
In-Reply-To: <20031020081758.GA14027@fede2.tumsan.fi>
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.
-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@accelinc.com
| President & Senior Geoscientist |
"Integration means more than having all the maps at the same scale!"
next prev parent reply other threads:[~2003-10-20 21:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-20 8:17 simple awk question urgrue
2003-10-20 20:19 ` Chuck Campbell
2003-10-20 21:09 ` Chuck Campbell [this message]
2003-10-21 14:51 ` Chuck Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031020210955.GA14839@helium.inexs.com \
--to=campbell@accelinc.com \
--cc=linux-admin@vger.kernel.org \
--cc=urgrue@tumsan.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).