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.
129
questions
23
votes
8
answers
19k
views
How do I sort by human readable sizes numerically?
for example I have command that shows how much space folder takes
du folder | sort -n
it works great, however I would like to have human readable form
du -h folder
however if I do that than I ...
19
votes
8
answers
6k
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, ...
19
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.
15
votes
2
answers
5k
views
Wrong behavior of sort command?
I tried to sort the content of a file in Ubuntu desktop 14.04 (Trusty Tahr). In my case, the expected result should be same as original content, but the actual result is not. Why?
# cat test.txt
a++-...
13
votes
4
answers
5k
views
Nautilus sorts the Name-column "mysteriously". How can I change the collating sequence?
What I describe here is not about a problem with my Nautilus. (it is the default behavour)
I understand why Nautilus sorts the Name-column (ascending) so that "6 cats" occuring before "10 dogs"... ...
12
votes
6
answers
72k
views
Identify duplicate lines in a file without deleting them?
I have my references as a text file with a long list of entries and each has two (or more) fields.
The first column is the reference's url; the second column is the title which may vary a bit ...
12
votes
3
answers
16k
views
Can I view my files sorted by date?
Can I view my files sorted by date?
I want to see my files sorted by date, I mean the first one the newest. I didn't find this option.
Thanks in advance.
11
votes
1
answer
5k
views
How do I force folder view sort order to not ignore special characters?
I have many folders in my home directory that have names that begin with special characters such as _OLD_500GB_HD or !FolderIWantToSeeAtTheTop, but for some reason these folders are sorted according ...
9
votes
3
answers
16k
views
How do I sort folders by actual size, instead of amount of sub-folders or files
I am pretty new with Ubuntu, so take it easy on me.
This is the "problem" (feature?) that I'm experiencing. It sorts by amount of folders and files, not by the actual file size.
I want to know much ...
8
votes
3
answers
19k
views
sorting a file using the sort command and overwrite it
i was trying to sort a text file and replace the sorted file with the original one, so i set the file to be also the output of the sort command too, but when i do that it clears the file contents and ...
8
votes
5
answers
3k
views
Searching through ODT documents without opening them?
Let's say I have 2000 .ODT files. Their names are random numbers. How do I go about searching for, let's say, "pricing list"? How do I find the document I need without opening all of them one by one ...
7
votes
2
answers
702
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 ...
7
votes
1
answer
19k
views
How to sort numbers in text files? [closed]
I made a file using ed and named it numeric. Its content is as follow:
-100
-10
0
99
11
-56
12
Then I executed this command on terminal:
sort numeric
And the result was:
0
-10
-100
11
12
-56
99
...
6
votes
1
answer
752
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....
6
votes
1
answer
775
views
How to sort by year-month-day from ascending using the "sort" command?
I want to sort dates in the format 31.12.2023. Lowest year should be displayed first then lowest month then lowest day.
Is the following code fitting my needs? Seems good on first look.
sort -t '.' -k ...
6
votes
1
answer
1k
views
How can I make a script to place files older than each day before into their own folder?
I'm running an unnecessarily complex script which looks similar to this command:
find /home/user/videos/*.avi -mtime +0 -exec mv -f {} "/home/nb/videos/1 day old" \;
And then I run the same command, ...
5
votes
2
answers
655
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 ...
5
votes
3
answers
9k
views
How do I sort account names alphabetically in Thunderbird?
I just upgraded to Ubuntu 12.04 and Thunderbird 13.0.1.
I had 2 accounts earlier in Thunderbird:
[email protected]
[email protected]
I also had another account on SeaMonkey:
[email protected]
which I imported into ...
5
votes
2
answers
905
views
Sort albums by date in Banshee
Banshee has an option - sort albums by release date, not by name, but turning it on do nothing. All tags are filled correctly. Is at a bug or I miss something?
5
votes
3
answers
1k
views
Music player that can sort or filter by number of tracks (per artist)
I'm looking for a music player/music library manager that allows me to see a list of artists sorted by the number of tracks I have for that artist. Winamp does this, but I haven't found any Ubuntu-...
4
votes
1
answer
4k
views
Sort command not working as intended on numbers
Here's my list.txt:
a 100
b 300
A 50
e 75
1 10
I ran the command below:
sort -k2,2 list.txt
This is what I got:
1 10
a 100
b 300
A 50
e 75
I am trying to only sort ...
4
votes
2
answers
21k
views
How to sort lines in a text file from the terminal?
I have to sort the GPA in a file for my class lab. The teacher uses putty, for those of us that chose to use Ubuntu in the class, we have no idea how to do the command for ascending sort and ...
4
votes
2
answers
1k
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 ...
4
votes
3
answers
5k
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: -...
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?
4
votes
2
answers
2k
views
How to make some folders appear on the top in Nautilus?
I'd like to have some folders on top e.g. on Windows I had _videos folder which would always appear on top. How do I achieve the same effect in case of Nautilus? It's rarely the case I'd need similar ...
4
votes
3
answers
151
views
sort a file based on the field 3 of the file contents
This is the contents of file
090100010000481074 1 08/03/2015 09:35:15.934 LA150803000AJSX00000 LA150803000AJSX CRBP Buy ELF 100 1980000 119 3 2 1890000 ...
4
votes
1
answer
633
views
Sort millions of text files in a folder using unix sort
I am trying to sort a lot of files (millions ie approx 2.5m) .txt files in a folder called NZParsed.
All the files in the folder are named like 1.txt 2.txt and so on till 25xxxxx.txt
After running ...
4
votes
1
answer
259
views
How can I make Nautilus sorting ignore the word "The" or "A" at the beginning of file and folder names?
I have a rather large library of media and it gets annoying looking for something when I forget that the "official" name of the movie, artist, song, etc begins with the words "The" or "A". So, for ...
3
votes
2
answers
3k
views
Reverse column output with sort command
I have to sort all of the words from a file given as parameter in a shell script.
Here is the one-liner:
tr [:space:] '\n' <$1 | sort -nrk2,2 | uniq -c |sed 's/^ \+//g'
Basically, if I have ...
3
votes
1
answer
6k
views
How to sort files by file extensions through the command line?
This is my question: How to sort files by file extensions through the command line?
3
votes
1
answer
271
views
Bash sort lines starting with punctuation in non-dictionary order
I have a file containing lines, some of which start with a ! character, some with a ? character, and some with a space ( ) character. The second character is always a letter of the alphabet.
When I ...
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:
...
3
votes
2
answers
2k
views
Sort lines in text file with specific separator in Linux
I need to sort the lines of a text file (without any extension) where the lines are separated by %. When using sort command, those %s are also getting sorted out which I do not want.
How to sort the ...
3
votes
1
answer
1k
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 ...
3
votes
1
answer
776
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 ...
3
votes
2
answers
1k
views
Sort files on nth character of name in a filemanager?
I would like to sort directories of files by a specified position in the filename using a "graphical" filemanager.
I have loads of files of this type (e.g.):
0001_oeirnglhk.ext
0002_gkggkcxiuv.ext
...
3
votes
1
answer
2k
views
How does uniq work? [duplicate]
Do not confuse this question to be a duplicate of "what is difference b/w sort -u and sort | uniq"
This is in essence a word count program
Confusion raised from the following command is reason for ...
3
votes
1
answer
274
views
Sort file/folder output in Bash
I have output like this (alphanumerical):
bash /etc/file
bash /etc/filenew
bash /etc/skel/
bash /etc/skel/file
bash /etc/skel/filenew
bash /etc/skel/new/backups/
bash /etc/skel/new/file
bash /etc/...
3
votes
1
answer
918
views
Can I sort files in Dolphin into date order on Kubuntu 12.04.01?
Can I sort files in Dolphin into date order on Kubuntu 12.04.01?
It was suggested (can't remember where) that Nepomuk would do this. If this is so, how do I enable Nepomuk. The application appears to ...
3
votes
3
answers
3k
views
Take the first n files from a directory starting with a particular letter in alphabetical order to another directory
I need to take the first 3 files from a directory starting with letter b in alphabetical order to another directory. I've come up with this command:
find /users/students/ejackson/A3-ejackson-55688-...
3
votes
1
answer
275
views
Move downloaded files based on criteria
After downloading tv shows and movies I would like them to be automatically moved to two separate folders (named "tv shows" and "Movies").
I know there are a lot of programs that you can do this with ...
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
...
3
votes
0
answers
437
views
How to make a new-defined alphabetic sort order in a locale work?
I'm working on a new Latin-based script for Persian. So I've used such lines in GB locale file, to modify the sort order:
First of all, I've introduced the new characters in such way:
collating-...
3
votes
2
answers
737
views
Change the Sort order of Devices in Nautilus
I have Three Windows drive,
my nautilus shows devices in following order
I want it to be sorted like windows 7 does
C drive
D drive
E Drive
My Massport
13 GB FS
Future attached removable mediums......
2
votes
2
answers
2k
views
Why are the outputs of `sort`, `sort k 1`, `sort k 1,1` equal?
I have a file:
$ cat file
1 c
8 a
1 b
5 f
I think the sort command in the beginning compares the first field of all lines and sorts them then for those lines have equal first fields and starts ...
2
votes
1
answer
2k
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-...
2
votes
1
answer
810
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 ...
2
votes
3
answers
2k
views
Insert a character in a filename, depending on filename length [closed]
I've got about 18k of files which are named this way:
0001_6548
0002_7674
...
14767_4536
I need to add a leading zero to filenames that contain only 4 digits in the first part, so they naturally ...
2
votes
1
answer
277
views
Using 'grep' and other utilities
I know this is a seemingly peculiar question, but I want to have a better understanding of using Linux utilities so I'm going to ask for something that seems rather complicated to me to understand the ...