Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | pk <pk@pk.invalid> |
|---|---|
| Newsgroups | comp.lang.awk |
| Subject | Re: getting fields of FILENAME |
| Date | 2011-04-13 19:48 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <io4rcu$aje$1@speranza.aioe.org> (permalink) |
| References | <a6764185-51cf-4a91-8694-feadacdc1fe9@glegroupsg2000goo.googlegroups.com> |
On Wed, 13 Apr 2011 11:48:52 -0700 (PDT) B <bryanlepore@gmail.com> wrote: > I am looking for some ideas on how to set a variable to be one field in > FILENAME. I'd like to do it within awk i.e. not piping to the shell. > > i.e. in a GNU toolchain the equivalent of: > > echo "one_two_three.dat" | cut -f1 -d'_' > one > > any suggestions appreciated. split(FILENAME, array, /_/); firstpart = array[1] or, in this case, also firstpart = substr(FILENAME, 1, index(FILENAME, "_")-1)
Back to comp.lang.awk | Previous | Next — Previous in thread | Next in thread | Find similar
getting fields of FILENAME B <bryanlepore@gmail.com> - 2011-04-13 11:48 -0700
Re: getting fields of FILENAME pk <pk@pk.invalid> - 2011-04-13 19:48 +0100
Re: getting fields of FILENAME Janis Papanagnou <janis_papanagnou@hotmail.com> - 2011-04-13 23:49 +0200
Re: getting fields of FILENAME Louis Frayser <frayser@earthlink.net> - 2011-04-13 18:33 -0700
Re: getting fields of FILENAME Ed Morton <mortonspam@gmail.com> - 2011-04-13 22:23 -0500
csiph-web