Questions tagged [sort]

Sort is a command-line program that allows standard input or specified text files to be sorted in various ways such as numerically or alphabetically, and then the result can be displayed in the terminal or sent to file.

Filter by
Sorted by
Tagged with
0 votes
0 answers
29 views

Case insensitive sort in Nemo

So I'm trying to get so special characters are on top followed by numbers, then letters case insensitive. I've added export LC_ALL=C to my .profile, but the result is case sensitive. Is there a better ...
0 votes
1 answer
56 views

How to sort Time/Date output?

Let's have 16:00_17/06/2022 12:31_10/05/2022 10:34_07/03/2023 11:17_12/04/2022 12:37_10/05/2022 I would like to sort this output in ascending order to get this: 11:17_12/04/2022 12:31_10/05/2022 12:...
  • 197
2 votes
1 answer
988 views

How to find duplicate lines in very large (65GB) text files?

I have 10 text files, that contain 65 characters of hex value in each line. Each text files is 6.5GB in size (having 99999999 lines) i.e.file1-6.5GB, file2-6.5GB, file3-6.5GB, file4-6.5GB, ... file10-...
  • 91
3 votes
1 answer
379 views

How to change `lsblk` sort order?

Change lsblk sort order lsblk sorts partitions in an order that is hard to follow. A method of sorting it without having to write a bash script or python script would be the first choice. A similar ...
7 votes
2 answers
602 views

How to sort files with a certain permission by size?

I need to sort all my files with 644 permissions by size. So far I've tried using the ls command to find and sort but they don't seem right. I think it may need a grep command but I think it needs to ...
  • 79
0 votes
2 answers
263 views

bash: sort files by a number inside them

I need to generate 100 .txt files with a random number inside each one of them. Then I need to rename the files so that the file names are named from 1.txt to 100.txt in ascending order based on the ...
  • 13
0 votes
0 answers
16 views

Sort wav files based on channel #

Is there a way to sort wav files based on channel number in a directory? For example, if I click Channel # for sorting it would. I'm surprised Ubuntu does not have this function.
0 votes
0 answers
200 views

C pipes with execlp(). Code works for "head" command but not for "sort"

So my job is to write a function that will work like: ps -ef| tr -s ' ' :| cut -d: -f1 | sort | uniq -c |sort -n Here is my code: void pipe4() { int pdesk1[2]; int pdesk2[2]; int pdesk3[2]; ...
  • 1
0 votes
1 answer
39 views

sorting by different columns in a sequence or sorting by multiple columns at once

What is the difference between sort -t' ' -k1,1n -k2,2n and sort -t' ' -k1,2n? Could you give examples? I've tried: logan@logan-mainPC:~/my-test/learn-sort$ cat myage my age 1 my age 100 my age 2 my ...
  • 123
0 votes
2 answers
399 views

Bash sort command numeric sort, fields and dictionary sort

Can you explain sort +0nr -2 +2d please? This example is from https://www.grymoire.com/Unix/Awk.html The comment says: # numeric sort - biggest numbers first # sort fields 0 and 1 first (sort starts ...
  • 123
0 votes
2 answers
190 views

Sorting based on text file

I'm trying to sort a text file based on the second field in the columns, so basically I have a file like "Year","District Code","District Name","Neighborhood Code&...
0 votes
2 answers
82 views

how to sort and clean up a text file?

I have massive text file with stupid data in it like "BR" (the BR had greater than/less than signs on either side of it, i have already removed the BR from the file, it just need it sorted ...
0 votes
1 answer
279 views

I can't make SORT with multiple columns work

sort -t ';' -k1,1 -k2,2 -k3,3 < unsorted (only column-1 in file 'unsorted' is sorted correct) 11;13;08 12;23;24 14;16;15 17;09;04
  • 1
0 votes
0 answers
82 views

How to correctly sort by numbers when having numbers higher than 9

I have a simple question. When I have a list of numbers and use sort, I get the following result: 10 11 12 7 8 9 Because 1 is lower than 7, it sorts 10 lower than 7. How can I make it so that it ...
  • 552
0 votes
1 answer
303 views

find files grep result then sort by file datetime modification

I have the following files **file_01.sh** abc bla bla function pause(){ bla foo function juliet(){ foo **file_02.sh** abc bla bla function pause(){ bla bla bla jjdjdjd foo function charlie(...
  • 63
0 votes
1 answer
53 views

Reversed file is empty after piping

I have just started learning Linux and having problem with understanding piping. I am wondering why reversed.txt is empty? I want to save unsorted file first, then pass to reverse sort, then save to ...
  • 3
4 votes
1 answer
3k views

GNOME - Sort menu entries alphabetically [duplicate]

I wish I could arrange the GNOME application menu alphabetically, but I can't find anything about this online... Is there by any chance a gsettings option or a script to do this?
  • 191
0 votes
1 answer
112 views

How am I misusing sort?

I have a very small file bugtest.csv with years in the seventh column. Its contents read: 1000,101,1,2,"VEN","Venezuela, Bolivarian Republic of",1967,22,4,99,0,0,1967-12-07,"R/...
  • 103
0 votes
0 answers
201 views

du /home | sort -nr +0 -1 | head –10

I am a little confused with this command. Can someone please explain what the output of this command is? I see it in my terminal, but I do not understand what it is showing me.
  • 1
0 votes
3 answers
800 views

sorting a csv file with 3 columns

I am trying to sort a csv file containing 3 values. The first one is the one that matters. It contains many times the number 1, 2, 3, 4 etc etc. But each number doesnt appear the same number of times ...
  • 21
0 votes
1 answer
237 views

Make "Files" to sort, columns shown & order PERMANENT

How ought one force Ubuntu Kitty v20 "Files" to PERMANENTLY(never changing, always the same, nonvolatile) Sort in a specific way, and PERMANENTLY display certain Columns and in a certain ...
user avatar
6 votes
1 answer
624 views

How to set memory usage sort in top command as default?

I want to sort the memory usage in top command as default. So that i do not have to sort in every i run top command. How to do that? Thanks in advance....
  • 415
2 votes
1 answer
165 views

How to invert sorting arrows? Aka sorting arrows are wrong

In a table, I feel the sort indicator symbol is wrong. I want: ▲ = ASC ▼ = DESC (or maybe even the other way around - depending on your needs)
  • 421
0 votes
1 answer
685 views

Sorting and moving a directory with files into subdirectories

Im using Linux Mint 19.3 Cinnamon, based on Ubuntu 18.04. (I hope Im not 'cursing in church' by that info .. ! But its functionally the same as Ubuntu 18.04 to 95%). Trying to move files in a folder ...
  • 3
3 votes
1 answer
412 views

How to display the 10 most recently started processes

I am trying to pipe the output of ps -ax -o pid,lstart into an awk and work with that or try to sort by a certain column using sort. The output of ps -ax -o pid,lstart is something like: PID ...
1 vote
1 answer
706 views

List unique result only on history command

I ran this command history | cut -c 8- It listed all the history commands as expected without line numbers. I'm wondering if there is a way to list only unique one. I've tried history | cut -...
  • 185
1 vote
0 answers
38 views

Music Library Sorting

I've tried a few different music players and they all seem to lack the one feature I want. It's possible they all have it and I just don't know how to use it, too. I've got a collection that's only ...
3 votes
2 answers
914 views

How do I preserve the line ordering for two "equal" strings while sorting and ignoring the case?

The contents of fred is: START test TEST tEST END From the bash terminal, sort fred returns: END START test tEST TEST All good. Now I type sort fred -f with the same result for sort fred. But ...
  • 809
3 votes
2 answers
2k views

sort is very slow for big files

I want to sort file (with removing duplicates) which contains wordlist with a size of almost 25GB. I am using sort command in Ubuntu terminal but it takes hours to output sorted file, the command is: ...
0 votes
2 answers
72 views

Getting the biggest partition on server

I'm trying to get the biggest partition out of "df -h" into a variable without success. Filesystem Size Used Avail Use% Mounted on udev 462M 0 462M 0% /dev tmpfs ...
  • 1
2 votes
1 answer
55 views

Directories aren't on the beginning of the view in Nautilus file manager, how to change this?

I am on Ubuntu 19.04. I have probably clicked some shortcut which changed directory view in Nautilus (Files application) and for a few days all directories are sorted like on the screenshot. I can't ...
0 votes
5 answers
85 views

Sorting each column and getting their corresponding key IDs in the first row for the bottom 2 values

This is my working file. (Column number and Row number are not known) key_ID col_1 col_2 col_3 AA 1 1 1 BB 56 2 7 CC 89 5 2 DD 7 77 7 I want to sort ...
  • 41
0 votes
0 answers
2k views

How to sort the file in such a way that join command accepts the sorted file?

I sorted two files and used join to merge the columns of the files according to row names. Commands I used sort file 1 > file1_sort sort file 2 > file2_sort join -o auto -e '0' -...
1 vote
1 answer
606 views

How do I sort a file based on both letters and numbers?

A file with this content: abc[0] abc[100] abc[101] . . abc[127] abc[19] abc[1] . . abc[9] xyz[0] xyz[100] xyz[101] . . xyz[127] xyz[19] xyz[1] . . xyz[9] I want to retain the ...
0 votes
2 answers
262 views

How to sort file after text-me-not/ in Unix and ignore case?

I have this data and want to sort it alphabetically after the string test-me-not/ and ignore case. hello-yourself/www/test-me-not/watermelon-green hello-yourself/www/test-me-not/orange-orange hello-...
1 vote
2 answers
122 views

extract the oldest values from a master file per each code

I need help writing a script that would extract from a master file the oldest records and save them in a separate file. The file contains hundreds of ISIN codes and additional data. For each, there ...
19 votes
8 answers
5k views

How to count occurrences of text in a file?

I have a log file sorted by IP addresses, I want to find the number of occurrences of each unique IP address. How can I do this with bash? Possibly listing the number of occurrences next to an ip, ...
  • 14.3k
-1 votes
2 answers
142 views

Sort ps result but with the first row instantly unchanged

I want to sort all the processes by Memory me@host:~$ ps au | sort -r -k 5 | head -10 | sed "s/$USER/me/g" USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND me 2312 0.0 0....
  • 1,590
0 votes
2 answers
477 views

using sort command while strings in first column repeats

I have a data file as follows; ALIC 5.55 2.65 3.45 ALIC 2.56 2.78 3.99 AMC4 3.55 3.66 4.88 AMC4 3.00 3.67 4.78 ALIC 1.00 1.00 1.00 ALIC 0.95 1.00 1.00 AMC4 0.50 1.00 1.00 AMC4 0.01 1.00 1.00 I need ...
  • 1,134
0 votes
2 answers
56 views

How can I sort a text file from number of occupied lines?

How could I sort a text files from number of ocupied lines? From: `He spoke to her, saying, "Dear child, can my servant and I find shelter for the night in this little house?" "Oh, yes," said the ...
17 votes
3 answers
4k views

How to sort search-results in Nautilus?

After upgrading to 18.04, I find that the File Manager will not allow sorting (date, type, name etc) after a search. It does allow sorts prior to a search. This change is not an improvement.
4 votes
3 answers
4k views

Sorting values and grepping the best score (highest number)

I have a file that looks like this: 7 C00000002 score: -41.156 nathvy = 49 nconfs = 2251 8 C00000002 score: -39.520 nathvy = 49 nconfs = 3129 9 C00000004 score: -...
  • 311
1 vote
1 answer
261 views

How can I sort fonts of different languages?

Is it possible to sort fonts of different languages instead of the alphabetical order which is the default sorting order?
  • 1,206
5 votes
2 answers
610 views

Creating a complete and alphabetically sorted .txt file of bash history

I want to have a complete and sorted list of my bash history. But there are some problems: By doing history the list never shows the complete list and only 1000 commands are shown. In my $HOME ...
user avatar
2 votes
1 answer
89 views

Extract number if lines from file in order of date file name

I have a folder with csv files whose file names are dates, viz.: January-01-2018.csv, January-02-2018.csv, ..., April-30-2018.csv. Using Bash preferably, I want to extract the number of lines from ...
  • 2,099
0 votes
1 answer
223 views

Run sort command in terminal

I have this file: root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin nickson:x:999:504:instructor:/home/SI/...
3 votes
0 answers
2k views

How to sort files files alphabetically rather than numerically in file manager

With "ls" the following files are sorted as I want as: 026 046 048 08f 28f 46a but in file manager (I have tried nautilus, nemo and pcmanfm) they are sorted as: 08f 026 28f 046 46a 048 ...
1 vote
2 answers
56 views

Visualize sorted storage volume use [duplicate]

My desktop storage capacity reaches its limit. How can I visualize my storage partition between files and apps (Android-like) to efficiently dig into the heaviest files?
  • 85
1 vote
1 answer
1k views

How can I use the "sort" command on a specific field?

In the below example (the original file is much bigger), how can I sort the lines w.r.t. line number of /185/ and /215/? /home/sorbilene/GAMIT_PROCESS/displacement/2/185/gsoln/res_2017-185_2017-186/...
  • 284
0 votes
1 answer
134 views

Wrong behaviour of "sort -u"?

[updated 12.11] I found a temporary solution for this. LC_ALL=C sort -u from bugreport here sort will get info from LC_ALL or LANG, My default is empty for LC_ALL, but zh_CN.UTF-8 for LANG. If ...