Read text-file with words and their occurrence count & print output sorted
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
I have a text file with the following format (retweets and username):
RT @username2 4
RT @Userddssdw 7
RT @usernam54 1
RT @Userddss44 1
RT @usernam1 1
RT @Userddssd1 6
Is there a way of sorting by occurrence and output the result like:
RT @Userddssdw 7
RT @Userddssd1 6
RT @username2 4
RT @usernam54 1
RT @Userddss44 1
RT @usernam1 1
Chris$ somethingIdontKnow | with grep | sort ./textfile.txt
grep sort
add a comment |Â
up vote
-1
down vote
favorite
I have a text file with the following format (retweets and username):
RT @username2 4
RT @Userddssdw 7
RT @usernam54 1
RT @Userddss44 1
RT @usernam1 1
RT @Userddssd1 6
Is there a way of sorting by occurrence and output the result like:
RT @Userddssdw 7
RT @Userddssd1 6
RT @username2 4
RT @usernam54 1
RT @Userddss44 1
RT @usernam1 1
Chris$ somethingIdontKnow | with grep | sort ./textfile.txt
grep sort
4
Have you looked atman sort
?
â DopeGhoti
Nov 28 '17 at 19:42
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have a text file with the following format (retweets and username):
RT @username2 4
RT @Userddssdw 7
RT @usernam54 1
RT @Userddss44 1
RT @usernam1 1
RT @Userddssd1 6
Is there a way of sorting by occurrence and output the result like:
RT @Userddssdw 7
RT @Userddssd1 6
RT @username2 4
RT @usernam54 1
RT @Userddss44 1
RT @usernam1 1
Chris$ somethingIdontKnow | with grep | sort ./textfile.txt
grep sort
I have a text file with the following format (retweets and username):
RT @username2 4
RT @Userddssdw 7
RT @usernam54 1
RT @Userddss44 1
RT @usernam1 1
RT @Userddssd1 6
Is there a way of sorting by occurrence and output the result like:
RT @Userddssdw 7
RT @Userddssd1 6
RT @username2 4
RT @usernam54 1
RT @Userddss44 1
RT @usernam1 1
Chris$ somethingIdontKnow | with grep | sort ./textfile.txt
grep sort
asked Nov 28 '17 at 19:39
Mees van Z
11
11
4
Have you looked atman sort
?
â DopeGhoti
Nov 28 '17 at 19:42
add a comment |Â
4
Have you looked atman sort
?
â DopeGhoti
Nov 28 '17 at 19:42
4
4
Have you looked at
man sort
?â DopeGhoti
Nov 28 '17 at 19:42
Have you looked at
man sort
?â DopeGhoti
Nov 28 '17 at 19:42
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
sort -r -g -k3 textfile.txt
This will perform a general numeric, reverse sort
of the output using the third field. -g
is a GNU specific option.
As mentioned by Jeff Schaller, the non-GNU specific option for a numeric sort
follows:
sort -r -n -k3 textfile.txt
This looks like it. Only when a number of 13 or 18 exist, it will see it as an 1 And lower than 9 I think
â Mees van Z
Nov 28 '17 at 19:53
1
Considersort -k3rn
â Jeff Schaller
Nov 28 '17 at 19:58
(-g
being specific to GNU sort)
â Jeff Schaller
Nov 28 '17 at 20:11
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
sort -r -g -k3 textfile.txt
This will perform a general numeric, reverse sort
of the output using the third field. -g
is a GNU specific option.
As mentioned by Jeff Schaller, the non-GNU specific option for a numeric sort
follows:
sort -r -n -k3 textfile.txt
This looks like it. Only when a number of 13 or 18 exist, it will see it as an 1 And lower than 9 I think
â Mees van Z
Nov 28 '17 at 19:53
1
Considersort -k3rn
â Jeff Schaller
Nov 28 '17 at 19:58
(-g
being specific to GNU sort)
â Jeff Schaller
Nov 28 '17 at 20:11
add a comment |Â
up vote
3
down vote
accepted
sort -r -g -k3 textfile.txt
This will perform a general numeric, reverse sort
of the output using the third field. -g
is a GNU specific option.
As mentioned by Jeff Schaller, the non-GNU specific option for a numeric sort
follows:
sort -r -n -k3 textfile.txt
This looks like it. Only when a number of 13 or 18 exist, it will see it as an 1 And lower than 9 I think
â Mees van Z
Nov 28 '17 at 19:53
1
Considersort -k3rn
â Jeff Schaller
Nov 28 '17 at 19:58
(-g
being specific to GNU sort)
â Jeff Schaller
Nov 28 '17 at 20:11
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
sort -r -g -k3 textfile.txt
This will perform a general numeric, reverse sort
of the output using the third field. -g
is a GNU specific option.
As mentioned by Jeff Schaller, the non-GNU specific option for a numeric sort
follows:
sort -r -n -k3 textfile.txt
sort -r -g -k3 textfile.txt
This will perform a general numeric, reverse sort
of the output using the third field. -g
is a GNU specific option.
As mentioned by Jeff Schaller, the non-GNU specific option for a numeric sort
follows:
sort -r -n -k3 textfile.txt
edited Nov 28 '17 at 21:27
answered Nov 28 '17 at 19:45
Timothy Martin
4,9542129
4,9542129
This looks like it. Only when a number of 13 or 18 exist, it will see it as an 1 And lower than 9 I think
â Mees van Z
Nov 28 '17 at 19:53
1
Considersort -k3rn
â Jeff Schaller
Nov 28 '17 at 19:58
(-g
being specific to GNU sort)
â Jeff Schaller
Nov 28 '17 at 20:11
add a comment |Â
This looks like it. Only when a number of 13 or 18 exist, it will see it as an 1 And lower than 9 I think
â Mees van Z
Nov 28 '17 at 19:53
1
Considersort -k3rn
â Jeff Schaller
Nov 28 '17 at 19:58
(-g
being specific to GNU sort)
â Jeff Schaller
Nov 28 '17 at 20:11
This looks like it. Only when a number of 13 or 18 exist, it will see it as an 1 And lower than 9 I think
â Mees van Z
Nov 28 '17 at 19:53
This looks like it. Only when a number of 13 or 18 exist, it will see it as an 1 And lower than 9 I think
â Mees van Z
Nov 28 '17 at 19:53
1
1
Consider
sort -k3rn
â Jeff Schaller
Nov 28 '17 at 19:58
Consider
sort -k3rn
â Jeff Schaller
Nov 28 '17 at 19:58
(
-g
being specific to GNU sort)â Jeff Schaller
Nov 28 '17 at 20:11
(
-g
being specific to GNU sort)â Jeff Schaller
Nov 28 '17 at 20:11
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f407573%2fread-text-file-with-words-and-their-occurrence-count-print-output-sorted%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
4
Have you looked at
man sort
?â DopeGhoti
Nov 28 '17 at 19:42