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
0answers
25 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]; ...
0
votes
1answer
29 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
2answers
97 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
2answers
104 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
2answers
30 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
1answer
126 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
0answers
37 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
1answer
102 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
1answer
35 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
votes
1answer
1k views

GNOME - Sort menu entries alphabetically

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
1answer
108 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
0answers
82 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
3answers
406 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
1answer
155 views

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

Excuse me Please: 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 ...
6
votes
1answer
514 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
1answer
103 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
1answer
348 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
1answer
204 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 ...
0
votes
1answer
297 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
0answers
36 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
2answers
658 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 ...
2
votes
2answers
1k 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
2answers
57 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
1answer
53 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
5answers
83 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
0answers
1k 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
1answer
490 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
2answers
212 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
2answers
115 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
8answers
4k 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
2answers
99 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
2answers
309 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
2answers
49 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 ...
16
votes
3answers
3k 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
3answers
3k 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: -...
1
vote
1answer
213 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?
5
votes
2answers
572 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 ...
2
votes
1answer
51 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 ...
0
votes
1answer
185 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
0answers
1k 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
2answers
53 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?
1
vote
1answer
984 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/...
0
votes
1answer
112 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 ...
0
votes
1answer
36 views

Sort only rows in a file [duplicate]

I want to sort only rows in my file e.g 5 2 2 1 and I want to have an output like this 2 5 1 2 Could someone help me ?
-6
votes
4answers
163 views

Wrong sorting a text file

I have this simple text file and want to sort all lines by the response_time column: 1 console-2017_09_17.log:2017-09-17 00:04:02,507:INFO :pool-8982-thread-30:r.a.u.j.PerfRequestInterceptor - method=...
2
votes
3answers
1k 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
1answer
2k views

Which LINUX command to be used for 'cut and replace a column' task?

http://paste.ubuntu.com/24184546/ This is the file. Here, I need to replace the 6th column with numbers from 1 to 158 respectively. The output should be like, http://paste.ubuntu.com/24184581/ How ...
-2
votes
2answers
132 views

Sort items in a folder according to given order

Suppose I have a file a.txt in which every line contains the line number (starting from 1) followed by a space and then followed by a name (the name of an item in a folder like e.g - something.mkv). I ...
4
votes
1answer
2k 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 ...
8
votes
3answers
10k 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 ...