3 ms·
Nice work! I don't know whether anyone here has used Rexx. The 'parse' instruction in Rexx was incredibly powerful, breaking up text by field/position/delimite
by kitd 5y ago
Nice work!
I don't know whether anyone here has used Rexx. The 'parse' instruction in Rexx was incredibly powerful, breaking up text by field/position/delimiter and assigning to variables all in one line.
I've often wondered if there was a command-line equivalent. Awk is great but you have to 'program' the parsing spec, rather than declare it.
- twic 5y ago> Awk is great but you have to 'program' the parsing spec, rather than declare it. You could probably turn a declarative spec into an awk program with an awk program.
- tyingq 5y agoNot declarative, but Perl can do something like that. Delimeters/Regex: $ perl -ne '($name,$pass,$uid,$gid,$therest)=split(/:/);print "$name $gid\n"' /etc/passwd root 0 daemon 1 bin 2 ... Fixed width: $ printf "1234XY\n5678AB" | perl -ne '($f1,$f2)=unpack("a4 a2");print "$f2 $f1\n"' XY 1234 AB 5678 I believe Rexx's parse is fancier still, but this is reasonably close.