[PLUG] awk string functions

2018-06-13 Thread Rich Shepard
I have many data files needing to be parsed and reformatted. The parsing is easy using the print statement, but I'm struggling to find an awk string manipulation function that reformats each field. Reading "Effective awk Programming, 4th Ed." leaves me uncertain whether to use sub(), gsub(), gen

Re: [PLUG] awk string functions

2018-06-13 Thread Russell Senior
Have you considered: man awk ? You probably want to look at substr(). On Wed, Jun 13, 2018 at 2:10 PM, Rich Shepard wrote: > I have many data files needing to be parsed and reformatted. The parsing > is easy using the print statement, but I'm struggling to find an awk string > manipulation fu

Re: [PLUG] awk string functions

2018-06-13 Thread Rich Shepard
On Wed, 13 Jun 2018, Russell Senior wrote: You probably want to look at substr(). I missed that one, Russell. I'll try it to figure out how to insert characters at specific places. Thanks, Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists

Re: [PLUG] awk string functions

2018-06-13 Thread Rich Shepard
On Wed, 13 Jun 2018, Russell Senior wrote: You probably want to look at substr(). Thanks again, Russell. I now have a one-liner: { print substr($1,1,4)"-"substr($1,5,2)"-"substr($1,7,2), substr($2,1,2)":"substr($2,3,2), $4 } That produces: 1988-10-01 00:30 0.75 1988-10-01 01:00 0.75 1988-