Questions tagged [sort]

Sorting text files or other data, for example with the sort utility.

Filter by
Sorted by
Tagged with
1
vote
2answers
52 views

How to sort the content of text file .txt by files size

the file has been generated by ls -Raltr -block-size=M /* > /home/root/all_files.txt I have tried several commands with grep to no avail.
0
votes
2answers
44 views

How do I count the occurrences in a list, and then sort by descending occurrence?

I have a list with 1601 lines, where on each line, I am interested in counting the # of times different values appear for fields 5. Here's what I have so far: awk '{print$5}' FILE | sort | uniq -c ...
-1
votes
2answers
43 views

How can i remove lines from a file when a string appears on multiple lines?

I have a file that has 2 columns like the following: apple pear banana pizza spoon fork pizza plate sausage egg If a word appears on multiple lines i want to delete all lines that the repeating word ...
0
votes
1answer
25 views

group list by last string of each line

I'm having a list of strings (sorted IP address ranges) like this: 10.100.0.0-10.100.255.255 External: 2.2.2.2 10.120.0.0-10.255.255.255 External: 2.2.2.2 10.0.0.0-10.255.255.255 External: 3.3.3.3 ...
1
vote
1answer
34 views

How do I sort files on multiple filename parts?

I have filenames in the format STR_NUM1_STR_NUM2_NUM3_NUM4_STR.dat. NUM1 repeats for many files. I want to sort the files first based on NUM1 and within each NUM1 group, I want the files to be sorted ...
3
votes
1answer
50 views

Why does ls sort results the way it does? [duplicate]

I'm just wondering why ls output is sorted the way it is: $ mkdir SortTest<br> $ cd SortTest<br> $ for a in {1..34}; do touch filename_$a.txt; done $ ls -l -rw-r--r-- 1 user user 0 Jun 28 ...
3
votes
2answers
251 views

“sort -nu” on uuids

anyone could explain why "sort -nu" returns only 1 unique line in example below? $ cat /tmp/test_ 1e971713-31e4-62d0-a3d1-37c0610c10e5 1e97d59f-bc32-6126-b7b1-0b52ddd35273 1e971713-31e4-62d0-a3d1-...
0
votes
1answer
27 views

Filter directory list text file based on the short common root directory

I have a list of directories similar to the below in a .txt file /Season_1/101 /Season_1/101/Thumbnails /Season_1/101/Thumbnails/Branded /Season_1/101/massive_screengrabs /Season_1/102/...
0
votes
1answer
28 views

copy-merge several folders contents, prioritizing newer files

I have few folders like this with their contents data/ -2011/ ---images/ ------logo.jpg ------banner.jpg ---reports/ ------monthly.pdf -2012/ ---images/ ------logo.jpg ---reports/ ------monthly.pdf -...
4
votes
1answer
59 views

Why does uniq drop korean string?

I have a CSV file containing 220k names that I want to batch import into a graph database. The batch importer imposes the restriction that each node must occur only once so I want to remove duplicates ...
2
votes
1answer
30 views

Does comma come before numbers when sorting?

I have a file foo whose contents are 140,22 236,224 2,86 If I sort it with sort foo I get the same result. This tells me that , comes after numbers, or at the very least that , comes after 3. ...
11
votes
5answers
2k views

How to sort human readable size

I'm basically looking for files then sorting by the size. The script works if I don't sort the size by human readable. But I want the size to be human readable. How can I sort sizes that are human ...
0
votes
0answers
27 views

Displaying a changing buffer in realtime in linux

Sometimes when I am searching for a song on my machine, I use the following: locate *artist*.mp3 | sort | less The thing about this is that the sort will buffer until all files have been located, ...
3
votes
2answers
80 views

Sort file by group of lines

If I have a file with contents similar to: FirstSection Unique first line in first section Unique second line in first section SecondSection Unique first line in second section ...
1
vote
1answer
39 views

Bash Script to create a file for each unique permission in a listing/find command and printing each directory/file path instance of that permission

I'm trying to create a bash script that will be able to perform a find command to get the permissions and full path of every file/directory in a directory tree and create a file for each unique ...
1
vote
1answer
19 views

How can I merge two sorted named pipes with uneven sizes?

My question is similar to "Merge two sorted files based on sorting values in the same field" but extending it to named pipes. Say I have two text files with sorted integers and I want to merge them. ...
0
votes
2answers
37 views

I have a text file with with 3 columns separated with : how to sort the second column by the last 2 digits of column 2?

This is an example of the text file: 195.92.211.47:21029:400 195.92.211.48:21023:400 How can I sort the lines of the file by second column's last 2 digits? The second column is always five digits.
0
votes
0answers
52 views

Sorting output content by file input

What the code does is that it prints depending on the line from a file the word that comes up the most. This is the code : for i in $@; do readlink -f $i while read line; do echo $...
8
votes
5answers
517 views

Sort a section of a file

Is it possible to sort between two strings in a large file ? e.g. Current file is as: 0cf Front Brake 0d0 Rear Brake 0ce Handle Bars HUT 03 VR Controls 009 Vest 001 Belt ...
1
vote
2answers
137 views

find n most frequent words in txt file using the terminal but with the cat, “grep .” and tr -d “/r” commands

I would like to find n most common words in a text file but with the following conditions: cat to get the file. grep . to get the words. tr -d '/r' to get rid of new lines. I've managed to get ...
0
votes
2answers
54 views

How to remove repetition of the content of file by column?

I have a file containing the following content: WP_021815421.1 OG5_132922 deth|YP_182312 3 -07 42.35 81.7 WP_021815427.1 OG5_128110 rbal|NP_868155 1 -55 50.72 53.2 WP_012456834.1 ...
1
vote
1answer
35 views

How to sort the second column in descending order? [duplicate]

I want to sort my input file on the basis of the 2nd column in descending order. I have used the following command for this: sort -k2,2nr input.txt > output.txt However, after running the command ...
0
votes
2answers
49 views

How to sort members alphabetically in /etc/group?

In my /etc/group file, I had the groups needed for various file shares, with their members listed. Some of these lists are quite long, and I'd like to find a way to sort the members of each group. Is ...
0
votes
1answer
37 views

How would you merge identical entries in the first column into one entry [closed]

Have a file where the entries are all over the place. Example: 10.11.12.13 tiger adfa afinhhdddd tiger 10.11.12.13 tiger tiger 123 10.11.12.13 tiger abc 10.11.12.13 tiger abc 10.11.12.13 TIGER ...
0
votes
1answer
43 views

What is the meaning of pos1 and pos2 under sort -k?

I want to understand the exact meaning of pos1 and pos2 under sort -k According to the manual -k, --key=POS1[,POS2] See POS syntax below.Start a key at POS1 (origin 1), end it at POS2 (...
3
votes
0answers
30 views

How can I debug or trace sorting for “LC_COLLATE=en_US.UTF-8 ls -l”?

(Unexpected sort order in en_US.UTF-8 locale explains the basics of UTF sorting) Consider this test scenarion: # touch abc{.{g,t,t.t},@.s,-{s-w,t.c}} # LC_COLLATE="en_US.UTF-8" ls -l test total 0 -...
0
votes
0answers
23 views

Nautilus alphabetical sort ignores 0

I noticed something interesting and strange in nautilus sorting method. Having a bunch of file named "foo01" to "foo10" plus another one named "foo011", ls returns them in alphabetical order, namely ...
2
votes
0answers
82 views

include special characters when sorting files

I'm trying to make Linux include special characters when sorting filesnames. The sort order I'm trying to achieve is: first all special characters, then numbers, then letters (case insensitive). The ...
0
votes
2answers
308 views

Uniq Descending Sort in a column

In the given data is it possible to uniq sort and print only the top hits against each region? Given Data aza1 18 bcn1 16 sat2 12 lcy2 12 fra1 12 aza1 12 bcn1 10 sat2 8 lcy2 9 fra1 13 aza1 21 bcn1 2 ...
-1
votes
1answer
29 views

Sort based on second column and list from highest to lowest

TGAAACATGCCTTTCACCTCCTGCCATGATTGTGAGGCCT 2 GTGTTGCCCAGGTTGGTTTCAAACTCAGCTCAAGTGATCT 1 GAGACTCCTTCAGGAGACTGGTCCCCTGTCCTCGCCTCTC 3 CATGTTCTCCTGGAAGCCATGTGAGGAAGGCACATCATGG 8 ...
7
votes
1answer
411 views

Sorting numerically

I have a file called data whose contents are id,col1,col2 0,-0.3479417882673812,0.5664382596767175 1,-0.26800930980980764,0.2952025161991604 2,-0.4159790791116641,-1.3375045524610152 3,-0....
3
votes
4answers
105 views

bash command to create array with the 10 most recent images in a dir?

I'm writing a bash script and I need to create an array with the 10 most recent image files (from new to old) in the current dir. I consider "image files" to be files with certain extensions, like ....
0
votes
2answers
65 views

sort a list numerically and alphabetically

I am trying to find most common word sorted alphabetically. for example: 2 went 2 wonder 2 wont 3 began 3 little 3 moment 3 rabbit 3 thing 3 till 4 alice 4 bottle 4 came 4 ...
0
votes
1answer
46 views

Does sort -u convert case?

If I have a file with some words starting with Capital letters and some starts with Small letters and some start with numbers or special characters. Does using sort -u input > output convert the ...
1
vote
2answers
79 views

du -sh * , hide directories with 0 usage

Here's what my current output looks like. 475M directorya 0 directoryb 0 directoryc 520M directoryd 42G somefolder Here is what I am trying to do. How do I hide the ...
-1
votes
2answers
80 views

Extracting Text between Two Strings in a Huge Ordered Text File

We have a huge text file containing millions of ordered timestamped observations and given the start point and the end point, we need a fast method to extract the observations in that period. For ...
0
votes
2answers
41 views

Find out which users are hogging the most disk space on our data server

We are supposed to store our ongoing projects on a rather small (~4TB) data server. Not surprisingly, it is constantly overflowing and people need to move off less recent files manually. Is there an ...
0
votes
4answers
77 views

Sorting the CSV based on Unix timestamp

I have a large number of CSV files, each file having multiple numeric columns. The first column is Unix timestamp. How can I sort such file? Thank you. An example row of the file as below: ...
0
votes
1answer
16 views

delete rows with duplications in first column in bash

I have a tab delimited .txt file and want to delete rows that have duplications in the first column. If this can be done without sort, that would be amazing, but I've kind of come to terms with that I ...
0
votes
1answer
35 views

sort -n doesn't work?

I am doing a usual thing that I sort -n but this time it does not work for the following input list, partially like ./firedock-output_308.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 54....
1
vote
2answers
61 views

How to sort comma-thousand separated numbers while on other locale

I have a German locale and need to sort US formatted numbers with commas as the thousands separator. Seems I don't override the locale properly? sort --version sort (GNU coreutils) 8.30 Example: ...
5
votes
1answer
345 views

bash sort -g does not work properly

I am trying to sort a data file in descending order. The data file is given by three columns and I want to order them in descending order for the third column with (the third column is given as a ...
1
vote
3answers
47 views

Sort File with word

I have a text file that looks something like this Name1 OpenFin Name2 Chrome Name3 OpenFin Name4 Chrome Name5 OpenFin Name6 OpenFin I want to sort this is a way where all lines with OpenFin appears ...
1
vote
4answers
94 views

Sorting elements of a CSV file

I have a csv file with seven numbers per line like this: 1083,20,28,42,23,10,43 1084,20,5,29,59,40,33 1085,39,50,21,12,40,55 1086,45,4,6,23,10,2 1087,36,46,28,32,3,20 I want to keep the first number ...
1
vote
3answers
49 views

Sort date in format “date +%a %b %d %T %Y”

I want to Sort the data in a file considering the date column (last column in the sample data). I have tried some commands but didn't get succeeded. Sample data: Beendet|48149|1550804401|STR|Fri ...
1
vote
2answers
76 views

Trying to sort specific columns in linux

I have been trying to sort specific columns with some data I have which is: ID Name Last Grade 123 Bill Holy A 747 Chloe Crown B 757 Aaron Farmer D 365 Gray Billson Column by ...
2
votes
2answers
69 views

Solaris : Sort numerical values

I have a file with following values. keyword1 19.02 1.69.94 keyword2 19.01 1.68.118 keyword3 19.02 1.69.119 keyword4 19.01 1.68.115 keyword5 19.02 1.69.304 keyword6 19.02 1.69.39 I want these to be ...
2
votes
1answer
82 views

Get the maximum value of all columns 1-3 with common column 4

Given an input txt file: $ cat input.txt -1 23 34 cheese 34 20 15 cheese -4 -4 20 tomato 13 -3 14 tomato 4 6 7 tomato -3 -3 -3 potato I can uniqify the data based on column 4, retaining the ...
0
votes
1answer
74 views

How to sort files in unix

I have files in the following manner ar01440_1775_17_vc00_00.png ar01440_1775_17_vc00_01.png ar01440_1775_17_vc00_02.png ar01440_1775_17_vc00_03.png ar01440_1775_17_vc00_04.png ...
2
votes
2answers
234 views

Alpine version-sort

How to do sort -V in alpine linux? sort: unrecognized option: V BusyBox v1.28.4 (2018-12-06 15:13:21 UTC) multi-call binary. Usage: sort [-nrugMcszbdfiokt] [-o FILE] [-k start[.offset][opts][,end[....