Search Results

Search: Posts Made By: juelillo
7,751
Posted By rdcwayx
Looks input file has been sorted. If not, sort it...
Looks input file has been sorted. If not, sort it first. :)
awk -F , '!a[$1]++ {printf RS $1 OFS $2 ;next}{printf FS $2}' infile

If not ask for space between first and second column, the code can...
7,751
Posted By Klashxx
Another aproach: perl -n -e...
Another aproach:
perl -n -e 'chomp;@b=split(/,/);if ($last ne $b[0]) {print "\n".$b[0]." " }else{print ","};$last=$b[0];print $b[1] ' file
7,751
Posted By danmero
awk -F, 'END{for(i in a) print a[i]}NR==1{print...
awk -F, 'END{for(i in a) print a[i]}NR==1{print $1 OFS "TRANSPOSED_"$2;next}{a[$1]=a[$1]?a[$1] FS $2:$1 OFS $2}' file
7,751
Posted By bartus11
awk -F, 'NR>1{a[$1]=a[$1]?a[$1]","$2:$2}END{print...
awk -F, 'NR>1{a[$1]=a[$1]?a[$1]","$2:$2}END{print "DOC_ID TRANSPONSE_KEYWORD";for (i in a){print i" "a[i]}}' file
1,168
Posted By Franklin52
Try this: awk '{print $0 FS a[$1]++ +1}' file
Try this:
awk '{print $0 FS a[$1]++ +1}' file
3,266
Posted By kevintse
try this: awk ' { ++a[$0] } END { for(s in a) {...
try this:
awk ' { ++a[$0] } END { for(s in a) { for(i=1;i<=a[s];++i) { print s, i, a[s] } } } ' inputfile

Note: your input data is assumed to be sorted.
Showing results 1 to 6 of 6

 
All times are GMT -4. The time now is 04:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy