Groups | Search | Server Info | Login | Register
| From | Louis Frayser <frayser@earthlink.net> |
|---|---|
| Newsgroups | comp.lang.awk |
| Subject | Re: getting fields of FILENAME |
| Date | 2011-04-13 18:33 -0700 |
| Organization | Netfront http://www.netfront.net/ |
| Message-ID | <io5isd$oju$1@adenine.netfront.net> (permalink) |
| References | <a6764185-51cf-4a91-8694-feadacdc1fe9@glegroupsg2000goo.googlegroups.com> |
On 04/13/2011 11:48 AM, B 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.
frayser@gentoo ~ $ var=this_is_a_record
frayser@gentoo ~ $ echo ${var//_/ }
this is a record
frayser@gentoo ~ $ Array=( ${var//_/ })
frayser@gentoo ~ $ echo ${Array[2]}
a
frayser@gentoo ~ $ echo ${Array[3]}
record
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
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