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

Questions tagged [sort]

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

1
vote
3answers
31 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
43 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
51 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
74 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
57 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
25 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
47 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
30 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
27 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
53 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
51 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
36 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
25 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
375 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
26 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
58 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
139 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
58 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
65 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
45 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
224 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
143 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
90 views

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

I am extremely confused, since a command I'm rather confident in, returns something completely different than I imagine! My assignment is simple: Find files (in a specific directory that is given) , ...
0
votes
1answer
133 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
116 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
36 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
48 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
29 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
112 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
41 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
70 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
77 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
77 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 ...
0
votes
5answers
115 views

get unique value for each line with unix command

I have a list as below: 1 2 5 2 1 5 5 3 1 5 5 5 5 2 2 2 2 2 4 3 I would like to sort each line and obtain the unique values as below, something similar to sort | uniq : 1 2 5 1 3 5 1 5 2 5 2 3 4 I ...
0
votes
2answers
42 views

I want to sort everything after fifth line

I have a list of something that I want to sort it, but like I said after fifth line... Right now I'm using this (it will sort everything): cat file.txt | sort > sortedfile.txt
25
votes
3answers
4k views

Why does sort say that ɛ = e?

ɛ ("Latin epsilon") is a letter used in certain African languages, usually to represent the vowel sound in English "bed". In Unicode it's encoded as U+025B, very distinct from everyday e. However, if ...
1
vote
2answers
83 views

Sort the files by size retrieved from a series of folders

I retrieved all the pdfs in $HOME directory $ find -E ~ -regex ".*/[^/].*.pdf" It print more than 1000 files; I intent to sort them by size and searched $ stat -f '%z' draft.sh 184 I drafts the ...
1
vote
3answers
40 views

Sorting blocks of data based on a particular row of data

I was given the below script by this great community to sort the rows of information. BEGIN { FS=":" PROCINFO["sorted_in"]="@val_str_asc"; } /./ { values[$1]=$0 } ...
0
votes
4answers
42 views

How to sort rows in a specific order as it's own block of rows

I want to sort the following rows of text to a particular order. The sort commands I am using is dropping the space and bundling all the lines together without the space separation and putting them ...
0
votes
1answer
50 views

ls: ordering by timestamp (reversed) and if the timestamp is the same order by name (not reversed)

I'd like to order a directory by reversed timestamp, but if the timestamp is the same order by name (not reversed) Using ls -tr if two files have the same timestamp order by name but in reversed mode
0
votes
1answer
52 views

sort with -k greater than number of keys

I'm trying to understand an existing script used in our project with the sort command sort -t= -nr -k3 nos Where nos is a file with whitespace and numbers, for this example: 997 998 999 1000 The ...
1
vote
3answers
126 views

How to sort a list with numbers and null values in ascending order?

I have a list of numbers and null values. How can I sort them in a way such that the null values come to the end of the list using sort in GNU coreutils? A sample column of input (input.data) 0.9000 ...
-1
votes
4answers
31 views

Multiplying digits inside numbers based on position of digit

I have list of numbers like this: 0987656787689 2345453326780 3453212332345 1324532449876 1234532444568 3245321343456 1324354532376 1234532153457 I would like to sort the numbers based on the ...
2
votes
0answers
46 views

Case-insensitive C locale

I'm trying to create a custom locale for use with the LC_COLLATE variable which sorts text just like the C locale, with the only exception that it sorts case-insensitively. I need this because I have ...
-1
votes
2answers
746 views

Sort with field separator [duplicate]

I'm trying to sort the /etc/passwd numerically by user id numbersb(third field) in ascending order and then send it to s4. What command would I uses to do that? I'm on this for a while now.
0
votes
1answer
59 views

How to sort on a field numerically

I am trying to sort a file called "Team_James" numerically by the last column, and then I would like to save the output as a new file called "file3". I tried the command sort Team_James | > s3, ...
6
votes
5answers
470 views

Ordering a string by the count of substrings?

I have long list of numbers like this: 1234-212-22-11153782-0114232192380 8807698823332-6756-234-14-09867378 45323-14-221-238372635363-43676256 62736373-9983-23-234-8863345637388 . . . . . . . . ...
1
vote
3answers
69 views

Windows explorer natural order sort order

I am kinda ingrained with the Windows sort order in my head. Unfortunately Windows doesn't really allow for an easy way to change it. Is there a way to emulate such sort order using unix tools? An ...