I have large csv file and want to build simple ranking:
$ cat file.csv
2022-12-01 RED 1
2022-12-01 RED 1
2022-12-01 RED 2
2022-12-01 RED 2
2022-12-01 RED 2
2022-12-01 YELLOW 1
2022-12-01 YELLOW 1
2022-12-01 YELLOW 2
2022-12-01 YELLOW 2
2022-12-01 YELLOW 2
$ sort file.csv | uniq -c | sort -nr > file_sort.csv
$ cat file_sort.csv
3 2022-12-01 RED 2
3 2022-12-01 YELLOW 2
2 2022-12-01 RED 1
2 2022-12-01 YELLOW 1
I want a result to be added as new column but instead its being added for existing $1 as below:
$ cut -f1 file_sort.csv
3 2022-12-01
3 2022-12-01
2 2022-12-01
2 2022-12-01
Is there any way to save the value of uniq lines as new column? Like this:
$ cut -f1 file_sort.csv
3
3
2
2