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
-1
votes
1
answer
450
views
How to obtain a list of all the files recursively without listing the directories to which the files belong and sort the list of files alphabetically? [duplicate]
I only managed to list the directories themselves with ls -a or the files sorted by directory with ls -aR
0
votes
3
answers
173
views
sort in shell using multiple -t
I have a file that contains:
192.168.130.175 2014-09-04 10:25:01 /index.html
192.168.138.244 2014-09-04 11:23:00 /index.html
192.168.138.244 2014-09-04 10:29:37 /...
0
votes
3
answers
101
views
Help finding files with the same filename (except what's inside parenthesis) and deleting the smaller size ones
I need to know how to find one or more files with the same filename (except what's inside parenthesis) and delete the one(s) with the smaller size, in a folder. I don't care if it's a GUI app or ...
1
vote
1
answer
125
views
Sorting a text file based on numerical values present in each line
I have a text file containing paths of various wav files. But when they are created they are sorted based on alphabetical order. Hence the paths are like this
/home/wav_path/...
3
votes
1
answer
409
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 ...
0
votes
1
answer
390
views
What files need to be copied into Ubuntu docker image to support da_DK.UFT-8 locale?
We have a docker image which runs Newman queries against a backend to verify things are as expected. Now we have a new need to test that a response containing Danish characters is sorted correctly in ...
0
votes
1
answer
386
views
How to use last to see how many times users logged in?
I need to see how many times users logged in.
I used last | sort | uniq -c but it gave me bad data
I need to sort them by number of times they logged in and only show username and number of time.
for ...
0
votes
0
answers
257
views
Tail in combination with sort
I use tail in a variable to echo contents of multiple files in a folder.
VAR="$(tail -n +1 DIR/*/file)"
This outputs all the files contents with the needed filename on top like
==> /...
6
votes
1
answer
875
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 ...
1
vote
0
answers
124
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
253
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:...
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-...
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 ...
7
votes
2
answers
742
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 ...
0
votes
2
answers
787
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 ...
0
votes
0
answers
21
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
1
answer
59
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 ...
0
votes
2
answers
1k
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 ...
0
votes
2
answers
247
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&...
-1
votes
2
answers
104
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
669
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
0
votes
0
answers
293
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 ...
0
votes
1
answer
814
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(...
0
votes
1
answer
89
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 ...
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?
0
votes
1
answer
116
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/...
0
votes
0
answers
358
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.
0
votes
3
answers
1k
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 ...
0
votes
1
answer
390
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 ...
6
votes
1
answer
879
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....
2
votes
1
answer
297
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)
0
votes
1
answer
1k
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
votes
1
answer
887
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
2k
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 -...
1
vote
0
answers
40
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 ...
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 ...
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
176
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 ...
2
votes
1
answer
57
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
92
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 ...
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' -...
2
votes
1
answer
872
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
302
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
131
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
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, ...
-1
votes
2
answers
174
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....
0
votes
2
answers
673
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 ...
0
votes
2
answers
58
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 ...
20
votes
3
answers
5k
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
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: -...