Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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
-1
votes
1answer
38 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
28 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
340 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 ...
1
vote
2answers
107 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
43 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
36 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
79 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
42 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
33 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
46 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
73 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
2k 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
37 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
28 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
vote
1answer
166 views

How do I tell grep after piping from cat to only highlight numerals greater than 720, or perhaps, more than two digtis?

It's a fairly simple question. If you would like to include additionally useful information about using grep in this manner, feel free.
0
votes
2answers
43 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 ...
11
votes
2answers
1k 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
1k 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
100 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?
6
votes
2answers
497 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
35 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
90 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/...
1
vote
0answers
650 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
40 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
303 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
64 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
35 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
123 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
303 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
962 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
122 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
621 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 ...
3
votes
3answers
4k 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 ...
3
votes
1answer
104 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 ...
0
votes
1answer
1k views

How to sort a file with bash

I have a file with one word on each line and I want to sort the file alphabetically. There's 2050 words in the file, so doing it manually would take a long time. Is there a bash script to sort it ...
2
votes
2answers
620 views

Sort from terminal is not working properly

I am trying to sort a text file by its second column. All the text in the file is in word /t number format (a word, tab, and it's weight). I am trying to sort the file by it's second column, by weight ...
1
vote
1answer
869 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 ...
2
votes
1answer
105 views

Sort files into subfolders acoording to name [script]

I have several files which were recovered from a backup but have the structure (file location) as the file name. eg: C\Users\Welcome\Desktop\Doc1.docx F\New folder\concerts\0904M002.WAV I want to ...
2
votes
2answers
800 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 ...
1
vote
1answer
2k views

How to sort files by multicolumn

My file has 3 columns and I want to sort the data in the file by column 1 (DESC), column 2(ASC) and save the result to another file. How can I do that?
0
votes
1answer
137 views

Create directories with names similar to files

I have a lot of .mp4 files, nearly 140, and I want to create directories with similar names to that of the files, but bash won't allow me to mkdir, saying file exists How can I do it ?
1
vote
1answer
523 views

How can I make the file browser sort in ASCII order?

The so called "intelligent sorting" does not make any sense to me. It will put 1z in front of 0005abz. I would like to have sorting order like it used to be: 00056 00056aaa 004abc 03abc 2abc and not ...
-1
votes
1answer
625 views

How long it will take to sort uniq a 62GB file? [closed]

For 5 hours I ran the command sort file1 | uniq > file2 on a 62GB file and I'm just wondering how long it will take. I have a Intel® Core™ i7-4510U CPU @ 2.00GHz × 4 with 8GB RAM. It will be ...
1
vote
2answers
2k views

How can I get the last occurrence of a repeated string in the text file?

I have a data file consists of several rows and columns with numeric and string data. Some string and numeric patterns are repeated. I need to extract last repeated pattern. For example; 715 ANKR PRN ...
1
vote
1answer
75 views

SORT: Why is it different in open/save window then elsewhere?

The sort order in my Xubuntu file manager (Thunar) is the way I want it, with types of characters in the following order: non alphanumeric (principally: underscore, hyphen, dot) numerics ...
3
votes
1answer
250 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/...
2
votes
2answers
1k 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 ...
1
vote
1answer
420 views

Sort and classify files using their name components (unix)

I have a folder with thousands of files respecting the following naming scheme: 'institute_model_scenario_river.txt' Each components of the files names (institute, model, scenario, river) are ...
0
votes
1answer
101 views

Sorting not working in ubuntu

I am running sorting script for existing file on ubuntu using bowl script: sort -r -k 2 -o mayflies.txt but terminal hangs and not showing anything, however it works without -o but i need to sort in ...
4
votes
3answers
125 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 ...