Given a file with some lines, I printed the content of this file (by uniq -c file
) and I want to sort this file and after it, I want to take only the lines (without the numbers from uniq -c
) , how can I do it?
I tried to do cat ${file} | uniq -c | sort -nr | cut -d" " -f2
, and I get empty output.
How can I fix it?
Exists way to remove all the spaces in the beginning of the lines that I get from uniq -c
?
For example:
given the following input:
a
b
c
a
a
g
d
d
I get the following output from cat file | sort | uniq -c
:
3 a
1 b
1 c
2 d
1 g
(In the beginning I get spaces)