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

learn more… | top users | synonyms

1
vote
4answers
39 views

How to extract first name in Alphabetical order from multiple files

Say I have File1: Aaron Vernon Troy Roy File2: Jason Derek Mariano Alex I want to display: File1: Aaron File2: Alex What would be a single line bash command that could do both? I was ...
2
votes
1answer
95 views

How to sort files separately without merging?

File1: Brazil New Zealand Argentina Uruguay File2: Chile Russia Latvia Switzerland I realize that the command sort -n File1 File2 will sort all the files merged together and display it ...
3
votes
4answers
140 views

Trying to sort two list of numbers and using uniq to get the intersection

I have a file A and B so I used to the following command... (sort -n A B) | uniq -d which should give me the numbers which occur in both files. 1 2 2 3 4 5 11 11 12 31 These are the numbers I ...
1
vote
1answer
41 views

Sort text by specific location on each line

What I want to achieve is sorting lines of text by a specific point in the text (the lines of text have no spaces or columns). I've worked out a solution to this, but I want to know if there is a more ...
0
votes
1answer
29 views

how to print the count of matched /unmatched patterns and print multiple patterns separated by line

how to print the count of matched /unmatched patterns and print multiple patterns separated by line. Input example (test.log): This 23 line has eight 8888 This 11 line has three 3333 need 12 to ...
1
vote
1answer
23 views

Nautilus: How are files sorted?

I am quite new to Debian 8.4. I am not sure if this is the right community on stackexchange to pose this question. Please tell me, if not. My question: I am using the Nautilus file manager. I view a ...
2
votes
0answers
49 views

Sort mount points by mount time

With no command line arguments mount displays all mounted file systems, e.g.: /dev/sdy8 on /bar type ext4 (rw,relatime,lazytime,data=ordered) /dev/sdx6 on /baz type ext4 ...
4
votes
5answers
102 views

How do I sort on the first column every 4 lines in a file with a key in the second column

Example File : first column can have fixed set of 4 unordered values world1.com,world2.com,world3.com or world4.com second column is a key belongs to each line such that each of the four sets has ...
5
votes
7answers
9k views

Sort the files in the directory recursively based on last modified date

Sort the files in the directory recursively based on last modified date I have modified a lot of files in my directory want to know what are those files by sorting them by the last modified date ...
18
votes
3answers
1k views

Scalability of 'sort -u' for gigantic files

What is reasonable scalability limit of 'sort -u' ? (in dimensions of "line length", "amount of lines", "total file size"?) What is Unix alternative for files exceeding this in dimension of "amount ...
0
votes
1answer
34 views

Using Perl for Even/Odd numbers

Currently, I'm using a process to create a very specific set of four files. The Process I'm using is shown in the attached Process Image, below: The first line is part of a solution, given to a ...
3
votes
3answers
83 views

Using grep/sort/find to extract unique values

I have a bunch of text files that are named in YYYYMMDD.Txt format (so today would be 20160420.Txt). Each file is basically a log that contains a timestamp and and a unique ID, each value is ...
41
votes
4answers
12k views

sort inplace - like sed --in-place - exists?

Am I blind or is there no option like --in-place for sort? In order to save results to the input file, sed uses -i (--in-place). Redirecting the output of sort to the input file sort < f > f ...
31
votes
2answers
44k views

Trying to sort on two fields, second then first

I am trying to sort on multiple columns. The results are not as expected. Here's my data (people.txt): Simon Strange 62 Pete Brown 37 Mark Brown 46 Stefan Heinz 52 Tony Bedford 50 John Strange 51 ...
3
votes
1answer
62 views

GNU sort --compress-program compressing only first temporary

I am sorting big files (>100Go), and to reduce time spent on disk writes, I am trying to use GNU sort's --compress-program parameter. (Related: How to sort big files?) However, it appears in certain ...
2
votes
1answer
59 views

POSIX Awk sort array

I would like to sort an array with POSIX Awk, however I have discovered that: asort() asorti() PROCINFO["sorted_in"] are all GNU extensions. Can this be done with without GNU Awk?
1
vote
0answers
19 views

gnu sort --stable option not working [duplicate]

I want to sort a text file with GNU sort, by the first field, with field separator ":": $ cat aa a:895502/ a:2013-05-24 # without --stable, last resort comparison $ cat aa | sort -t: -k1 a:2013-05-24 ...
3
votes
3answers
199 views

Join two files each with two columns, including non-matching lines

I'm trying to match and merge two sets of sorted data, one set per file. Each file contains two columns: the key field and the associated value. The resulting output should contain three columns: the ...
2
votes
3answers
100 views

How to sort files in Bash with ddmmyy timestamps in name

I have a series of files with names of the form "foo.date.bar" where "date" is a six digit field such as 310715. So for example foo.310715.bar foo.260815.bar foo.110815.bar foo.040815.bar I would ...
0
votes
1answer
67 views

removing duplicates with tail [closed]

How can I remove duplicate in tail output? I'm using tail -f file.txt | sort file.txt | uniq it stops tail after some sec
3
votes
2answers
33 views

Sort by last character of input, then by preceding number?

I have a file that looks like this: foo03a foo02b quux01a foo01a foo02a foo01b foo03b quux01b I'd like it ordered by the last character (so a and b appear together) and then by the preceding ...
0
votes
1answer
35 views

linux - setting order in which files are read or output with utilities (sorting)

I'm having issues with programs reading files in the wrong order, and also outputting in an undesirable order with utilities such as ls. I've tried some of the LC_COLLATE options, but none of them ...
4
votes
1answer
58 views

What is the sort order when using conditional operators?

I wrote a bash script that processes a list of filenames (using glob expansion, as in for f in *) and then outputs a subset of this list to a file. Subsequently I read the content of this file into an ...
0
votes
1answer
75 views

sort files twice

I have a series of 300+ files that I need to sort twice, once by the date and a second time within that date by part of the filename. The only standard in the names is that ends with *mmddyyyy<time ...
3
votes
2answers
47 views

Sorting by two columns

I need help with this homework assignment: Write a shell script named sales1 using nawk and sort commands to do the following: 1. print the file in two sections, east and west, with lines alphabetized ...
3
votes
2answers
61 views

Sorting based on last occurrence of character

I want to sort the file based on the text before the first comma, but also want a second level sort based on the date YYYYMMMDD in the sample input: Sample Input: ...
0
votes
1answer
44 views

Monitoring Server Connections - Netstat formatting issue

I have had a few issues with a server recently. So i just wanted to leave a window showing the unique and IP's of connected devices. I have been using: watch -n 5 "netstat -tn 2>/dev/null | grep ...
3
votes
1answer
43 views

Sorting Directories and Files

I want to use find and sort the response. I assumed that a simple pipe find ... | sort would do it, but the sorting behaviour is weird. For simplicity a simple text file: asdf/2/22 asdf/2/01 ...
-1
votes
1answer
24 views

Sorting and outputting in another file

How can I sort a file then output it into another file I never created or do I have to create the file I want to put in. Might not make sense how I am typing it so... Let's say the file I have is ...
2
votes
5answers
42 views

How do I sort mixed text&numbers (eg hostnames)?

Given input with mixed text and numbers (w/o leading zeros), how can I get it sorted in the "natural" order? For example, given the following input (hostnames): whatever-1.example.org ...
1
vote
1answer
30 views

Calculate hits within a timespan from log file [closed]

I need to use UNIX utilities that implement out-of-core divide-and-conquer algorithms so to decrease the amount of virtual memory used (cap of 1 mb). I have a large data set that is an apache log ...
2
votes
2answers
80 views

Sorting ls output where files end in numbers [duplicate]

Here is the output of my normal ls command: f1 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f2 f20 f3 f4 f5 f6 f7 f8 f9 So I have 20 files. I need them displayed as : f1 f2 f3 f4 ...
3
votes
2answers
45 views

How to pin certain files when using sort?

Normally I am more creative with Unix commands and pipes, but not today. So what I have is this: collage.jpg DCIM001.jpg DCIM002.jpg or this: 001.jpg 002.jpg boston-collage.jpg or sometimes ...
3
votes
1answer
32 views

Sort log data with bash

I have a log file containing such entries 192.168.1.1;query=/etc/security/limits.conf;date=02.03.16 192.168.1.1;query=/etc/security/limits.conf;date=01.06.15 ...
0
votes
1answer
65 views

aix: how to sort ps by stime?

On AIX, for the top 10 cpu processes, I use ps aux | head -1; ps aux | sort -rn +2 | head -10 for the top 10 mem processes ps aux | head -1; ps aux | sort -rn +3 | head -10 How can I sort the ...
1
vote
1answer
30 views

sorting on two vertical columns

I have a file that I want to sort from the nth column (which is numeric) - not the nth field. The file looks schematically like: 1 Here are four words 9 8 5 2 Here's two 7 2 6 ...
0
votes
0answers
29 views

sort on column (not field) [duplicate]

I have a file that I want to sort on the nth column (which is numeric) - not the nth field; i.e. the file looks schematically like: Here are four words 9 Here's two 7 One ...
21
votes
5answers
7k views

How can I remove duplicates in my .bash_history, preserving order?

I really enjoying using control+r to recursively search my command history. I've found a few good options I like to use with it: # ignore duplicate commands, ignore commands starting with a space ...
2
votes
3answers
970 views

Creating recursively sorted RAR archive

For various reasons I decided to use RAR archive to store some data, instead compressed tar. Happy with decision, except for one thing: I can't find a way to store files sorted. Order of files is ...
16
votes
3answers
26k views

Sort and count number of occurrence of lines

I have Apache logfile, access.log, how to count number of line occurrence in that file? for example the result of cut -f 7 -d ' ' | cut -d '?' -f 1 | tr '[:upper:]' '[:lower:]' is a.php b.php a.php ...
1
vote
2answers
54 views

How to reverse sort the output from grep -rc

I want to be able to sort the output from the grep -rc command, I am currently using the command: grep -rc "Pattern" . | sort -t: -rk2,2n however the list is still sorted from low to high, ...
0
votes
2answers
46 views

File sort by time issue

I have a requirement to identify sequence gap in a set of files. Sequence starts at FILENAME_0001 and ends at FILENAME_9999. After this the sequence is restarted from 0001. To implement a proper ...
3
votes
2answers
153 views

Is there a way I can grep recursively over all the files in the current directory to find a pattern and then print it in order of high to low?

So so far, the code looks like this: grep -rc 'Author' $1 It prints out all the files in the directory, which is taken as an argument. However, how would I sort the output (for example): - ...
1
vote
1answer
36 views

Why do different installations of sort sort punctuation differently?

I got a file with content like this: ----------- =========== -------- -=-=-=-=-=- When I sort in a linux os, it comes like this: $ sort 1.txt =========== -=-=-=-=-=- -------- ----------- ...
5
votes
5answers
2k views

Sort input file by the results of a regex

I'd like to sort a file based on the results of a regex expression. For example, if I have the following property declarations in Obj-C @property (nonatomic, strong) id <AlbumArtDelegate, ...
3
votes
2answers
70 views

How to sort data by the numbers in third column? [duplicate]

If I have a file consisting of data that looks as follows, how would I sort the data based on the numbers in the 3rd column ? The space between the first two columns are NOT tab delimited but some ...
0
votes
2answers
44 views

sort each column(field) in a file separately [duplicate]

I am aware that it is possible to sort primarily by one field and secondarily by another field. For example: $ echo -e "1 5\n1 4\n8 2\n1 9" | sort -k 1,1n -k 2,2n 1 4 1 5 1 9 8 2 $ However, am I ...
8
votes
3answers
1k views

sort at jobs chronologically

Possibly a simple solution I misplaced. How can I get the output of atq sorted chronologically, so I can easily see who's due to run next? The man page for sort doesn't have anything built-in to ...
10
votes
1answer
235 views

How to sort a file based on a section of a field

I would like to sort a file : D104HN-D104HA 8.320 4.521 1.69e+05 -- D104HN-D104HB* 8.320 2.823 2.93e+05 -- A90HB#-A90HA 1.655 4.207 7.12e+05 -- ...
0
votes
1answer
28 views

sorting a file on column 1 [duplicate]

I have a file in this format which I want to sort RNU2-46P 0 RNU2-2P 9 RNU2-63P 5 RNU2-36P 6 RNU2-56P 8 RNU2-17P 0 I want to sort it on column 1 and get this output RNU2-2P 9 ...