![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| unique sort contents of a variable | praveenbvarrier | Shell Programming and Scripting | 2 | 05-20-2008 04:12 AM |
| how to sort, and count unique data all at once? | amatuer_lee_3 | Shell Programming and Scripting | 13 | 05-15-2008 07:48 AM |
| sort function in perl | DILEEP410 | Shell Programming and Scripting | 2 | 09-14-2007 05:03 AM |
| sort and uniq in perl | reggiej | Shell Programming and Scripting | 4 | 05-18-2006 07:46 PM |
| Sort file in perl | annececile | Shell Programming and Scripting | 4 | 06-21-2002 05:52 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Sort and Unique in Perl
Hi,
May I know, if a pipe separated File is large, what is the best method to calculate the unique row count of 3rd column and get a list of unique value of the 3rdcolum? Thanks in advance! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
read the file line by line and use a hash to get the unique values of the 3rd column.
|
|
#3
|
|||
|
|||
|
Could you kindly explain with one simple example.
|
|
#4
|
|||
|
|||
|
Maybe realy simple:
cat $file|awk -F\| '{print $3}'|sort -u (I think some awk guru can do it with less commands)... I saw to late you meant perl.. sorry |
|
#5
|
|||
|
|||
|
Quote:
But looking for perl methods! |
|
#6
|
|||
|
|||
|
read the file
split the record use the third field populate in a hash => this would maintain uniqueness when displaying use sort keys %hash |
|
#7
|
|||
|
|||
|
Quote:
Code:
awk -F"|" '{ print $3 }' file | sort -u
|
|||
| Google The UNIX and Linux Forums |