besogon has asked for the wisdom of the Perl Monks concerning the following question:
I have a file looking like this:
field1=value1, field2=value2, field3=value3 field1=value1a, field2=value2a, field3=value3a
need to extract the values only:
value1 value2 value3 value1a value2a value3a
This oneliner works but looks lame:
cat file.txt | perl -ne 'm!.*=(.*),.*=(.*),.*=(.*)!; print "$1 $2 $3\n +"'
Doing it for a 10 field file would be too much. Is there a way to start delimeter using one field and end using a different character? Can array be used?
Please help.
thank you in advance
2017-08-01 Athanasius added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: one liner function
by Anonymous Monk on Aug 01, 2017 at 04:46 UTC | |
|
Re: one liner function
by Laurent_R (Canon) on Aug 01, 2017 at 14:49 UTC | |
|
Re: one liner function
by Laurent_R (Canon) on Aug 01, 2017 at 07:14 UTC | |
|
Re: one liner function
by AnomalousMonk (Archbishop) on Aug 01, 2017 at 14:09 UTC | |
|
Re: one liner function
by NetWallah (Canon) on Aug 02, 2017 at 03:24 UTC |