in reply to Re: Delimited File Analysis One-Liner?
in thread Delimited File Analysis One-Liner?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Delimited File Analysis One-Liner?
by BrowserUk (Patriarch) on May 02, 2012 at 16:19 UTC | |
by temporal (Pilgrim) on May 02, 2012 at 19:13 UTC |