Quantcast
Channel: How to print specific duplicate line based on fields number - Stack Overflow
Browsing latest articles
Browse All 5 View Live

Answer by glenn jackman for How to print specific duplicate line based on...

Use [ as the field delimiter, then split the last field on ,:awk -F '[[]'' {split($NF, f, /,/)} length(f) > max[$1] {line[$1] = $0; max[$1] = length(f)} END {for (l in line) print line[l]}'...

View Article



Answer by potong for How to print specific duplicate line based on fields number

This might work for you:sort -r file | sort -t, -k1,1 -u

View Article

Answer by Zsolt Botykai for How to print specific duplicate line based on...

Something like this might work:awk 'BEGIN {FS="["} Ff != gensub("^([^,]+).*","\\1","g",$0) { Ff = gensub("^([^,]+).*","\\1","g",$0) ; Lf = $NF ; if (length(Ml) > 0) { print Ml } } Ff ==...

View Article

Answer by kev for How to print specific duplicate line based on fields number

generate index file$ cat input.txt |sed 's/,\[/|[/g' | awk -F'|''{if(!gensub(/[[\])]/, "", "g", $NF))n=0;else n=split($NF, a, /,/); print NR,$1,n}' | sort -k2,2 -k3,3nr | awk '$2!=x{x=$2;print...

View Article

How to print specific duplicate line based on fields number

I need to print out only one of various consecutive lines with same first field, and the one must be the one with "more fields in its last field". That means that last field is a set of words, and I...

View Article

Browsing latest articles
Browse All 5 View Live


Latest Images