Thanks for the tip, BrowserUk. Always fun to learn a new trick.
I've generalized your code to match any column, where i is the column:
perl -F, -anE '$m<($x=length $F[i]) and $m=$x}{say $m' file.csvI'd still use yours if I'm only looking in the first column. I wonder if there's a way to continue on that same idea (using index) and count delimiters out to a particular column and then save the distance between the most recent delimiters. Probably wouldn't be a one-liner at that point.
Also, curious about your use of $1. Is it a shell variable? Executing your command as written (in bash) doesn't give me any output, I have to switch the single and double quotes. Then I have to use a different variable, Perl won't let me assign to $1.
In reply to Re^2: Delimited File Analysis One-Liner?
by temporal
in thread Delimited File Analysis One-Liner?
by temporal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |