Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [sort]

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

0
votes
2answers
31 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
26 views

Sort based on second column and list from highest to lowest

TGAAACATGCCTTTCACCTCCTGCCATGATTGTGAGGCCT 2 GTGTTGCCCAGGTTGGTTTCAAACTCAGCTCAAGTGATCT 1 GAGACTCCTTCAGGAGACTGGTCCCCTGTCCTCGCCTCTC 3 CATGTTCTCCTGGAAGCCATGTGAGGAAGGCACATCATGG 8 ...
7
votes
1answer
366 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
3answers
59 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
50 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
44 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
votes
2answers
73 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
37 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
67 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
15 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
26 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
38 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
324 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
43 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
75 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
41 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
53 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
57 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
77 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
71 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 ...
0
votes
2answers
70 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[....
0
votes
2answers
49 views

How can I compare two files by using just two columns and print the difference (without sorting)?

I have two files: File 1: No ID CV CA1 CA2 1 transcr_10283 0.999023367236861 -0.344113101336184 -0.032235130455987 2 transcr_10371 -0.572755303094372 -0.579145581184253 0....
1
vote
1answer
39 views

Does the size of the random_source file matter?

Some GNU coreutils utilities like sort and shuf use a file as what effectively serves a seed. Does the size of the file matter? The recommended way, https://www.gnu.org/software/coreutils/manual/...
0
votes
1answer
62 views

Terminal sort command options: sort -k1,1

cat input.txt | sort -k1,1 I am trying to figure out what the ,1 part at the end does in this command. input.txt is a 2 column file. First column is some word and second column is the number 1. -k1 ...
2
votes
1answer
54 views

Sorting structured file with bash commands

I need to sort a LDIF file, where several lines belonging to a parent one. Example dn: 2 attr1: b attr2: a attr1: a attr1: c dn: 3 attr2: a attr1: c attr1: b attr1: a dn: 1 attr1: a ...
1
vote
2answers
64 views

How to sort a file with multiple delimiters?

Listing the available patches in openSUSE results in the following output. The command that results int the details below is zypper patches. The same result is also displayed when running the ...
0
votes
1answer
43 views

Find + -printf + sort conflict?

I need to pass a list of sorted, quoted FLAC file names to SoX for concatenation but am having trouble getting sort to work the way I expect it to. If I use: find . -maxdepth 1 -type f -iname "*....
1
vote
1answer
26 views

collect logs from bash each 24 hours [closed]

my idea is to collect logs each 24 hours ,mail it and flush them after that i wrote some scatch for example 1.var/log/auth {some info} 2.var/log/something.log {some info} list="$(find /var/log -...
6
votes
5answers
380 views

How to sort by odd lines then remove repeated values?

I have the following type of file: transcr_25793 + YAL039C - transcr_25793 + YAL037C-B - transcr_20649 + YBL100C - transcr_7135 + YBL029C-A - transcr_11317 + YBL067C - transcr_25793 + YAL038W + ...
0
votes
0answers
54 views

Sort folders before files for only a specific directory

In Ubuntu 16.04 LTS is easy to sort/not sort folders before files. In Files program, by selecting Edit > Preferences, just mark/unmark Sort folders before files, as shown in the figure below. The ...
0
votes
2answers
61 views

awk how to sort within a row from left to right within row?

I have a large datafile with xml type tags. Each row refers to a unique item and contains a different number of attribute fields. I need to sort the rows based on numbered tags in that row from lowest ...
4
votes
1answer
148 views

Sort multiple delimited file lexicographically by one column, numerically by another

I wish to sort the TSV file below (called min_ex) by the first column lexicographically and by the second column numerically. A X, N 2.2 A, N 5.7 A, A 5.8 A, N 2.1 A, T 0.2 B G, M 2....
0
votes
1answer
60 views

command sort -h does not return a reasonable result [duplicate]

I tried to sort files using sort -h algorithms@algorithms:~$ ls -lh /boot | sort -h drwxr-xr-x 5 root root 4.0K Dec 28 16:19 grub -rw------- 1 root root 4.2M Dec 5 13:10 System.map-4.18.0-13-generic ...
0
votes
1answer
83 views

How to configure Linux Mint in order to file manager sort filenames using different algorithms?

I'm not being able to sort files the way I want with my file manager on Linux Mint and I would like to know if there's any hidden config to change that. For example, I'm sorting: "a.txt", "(b).txt", ...
0
votes
3answers
46 views

I want to sort the file based on column information

When I run my input file I get a file that contains 758 lines that look like this. DISTANCIA1.45_SIMETRIA1_GIRO2_ACTIVOS11/MoN-MVW.out::: Total energy: DISTANCIA1.45_SIMETRIA1_GIRO2_ACTIVOS7/MoN-...
2
votes
3answers
375 views

How do I sort an array with letters and numbers combined in bash? [duplicate]

I have an array with h4 h5 h1 h2 h3 in it and I would like to sort it according to the numbers, but don't know how. What is the best way to do this? edit1: I would also like to sort an array via the ...
2
votes
2answers
262 views

Sort lines according to date and time

I have this file which represents a calender. Each file has the exact date and time, then the name event and a note. 06-12-2016,12:00,gym,leg day 05-04-2018,12:09,gym,hands 09-08-2019,13:08,movies,...
17
votes
3answers
1k views

Sort not sorting lines with a pipe '|' in it correctly

I am trying to sort some simple pipe-delimited data. However, sort isn't actually sorting. It moves my header row to the bottom, but my two rows starting with 241 are being split by a row starting ...
0
votes
2answers
220 views

Find files greater than X value, sort by size, show in ls format

My assignment is: Find files (in a specific directory that is given) , show only the ones above 100 megabytes, sort them by size, print them in ls -lh format. This is what I execute: find /home/...
0
votes
1answer
260 views

how to sort file by DD-MM-YYYY dates

in a file containing : ... 18-11-2018:othercharacters 10-11-2018:othercharacters 03-10-2018:othercharacters 30-10-2018:othercharacters 27-09-2018:othercharacters 03-12-2018:othercharacters ... the ...
4
votes
3answers
167 views

How to merge pre-sorted files into a single BIG file, without excessive memory or temporary disk use

I'm trying to sort (and ideally remove duplicate lines) from a 1.4TB file. Splitting and sorting the individual chunks is not an issue, but reassembling them is turning out to be a challenge. I ...
0
votes
3answers
65 views

Script - Cutting various lines and sort them

i want to sort the process of one user by the percentage of cpu used. I tried this ps aux|tr -s " "|cut -f3 -d " "| sort -| grep "user" > file name does this work?
0
votes
1answer
53 views

Shell script sort

Im trying to sort a small file with some entries containing two words but i want to sort this as one entry. for example consider this small list peter barker painter carl baker cook joshua ...
2
votes
1answer
33 views

Does sort --unique -k drop duplicates in original order?

I'm doing a unique sort on a concatenated set of index files where the first column will sometimes change between each index and the second column will be a key value (actually hex addresses). Each ...
9
votes
6answers
1k views

Bash sort array according to length of elements?

Given an array of strings, I would like to sort the array according to the length of each element. For example... array=( "tiny string" "the longest string in the list" "middle ...
2
votes
2answers
127 views

tsort: -: input contains an odd number of tokens

coreutils manual says tsort reads its input as pairs of strings, separated by blanks, indicating a partial ordering. The output is a total ordering that corresponds to the given partial ...
0
votes
1answer
42 views

Can I merge-sort two sorted files by using comm?

comm assumes its two inputs are sorted. Is it correct that it works in the same way as the merge sort algorithm? If yes, can I use comm to merge-sort two sorted files? Thanks.
-1
votes
1answer
86 views

Find unique lines, ignoring certain columns

I want to be able to go through a file and find lines that are different in the fields I expect to be stable, ignoring differences in the fields I know will be different. I want to ignore columns 2,5,...
1
vote
5answers
89 views

Linux: Find the second biggest file/directory in size using commands

Introduction Find the second biggest file/directory in size using commands. What I have du /etc/ -hsx * | sort -rh | head -2 This command shows me two lines which, by the options I've chosen, gets ...
-1
votes
1answer
148 views

Sort `du -sh` in an reasonable order [duplicate]

I want to check the disk usage with a readable size (option -h) [root@iz2ze9wve43n2nyuvmsfx5z /]# du -sh ./* 2>/dev/null | sort -nr 914M ./var 568K ./tmp 523M ./root 496K ./run 156M ...