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

learn more… | top users | synonyms

1
vote
2answers
212 views

`echo -e 'Q\ns\nV' | sort` doesn't sort

Why do : $ echo -e 'Q\ns\nV' | sort outputs Q s V without changing the order of my list (taking in account the lower/uppercase ?)
1
vote
5answers
98 views

How to get the unique count of a particular part of a string

I have a set of data in a file. psf7433-nlhrms unit7433-nobody unit7333-opera bpx7333-operations app7333-osm unit7330-partners psf7331-pdesmond unit7333-projm mnp7330-redirect unit7333-retailbanking ...
1
vote
2answers
81 views

how to sort files by their permissions using ls?

I have a large number of files and directories in one directory. I need to sort them in terms of the permissions. For example drwx------ drwxr-xr-x drwxr-x--- I am just wondering if we can sort ...
1
vote
4answers
156 views

Sed/awk/perl: reversing order of comma separated values, preserving other text

I have this text: LABEL1 .BYTE 01, 02, 03, 04, 05 .BYTE 01, 02, 03 I need to reverse only comma separated values order: LABEL1 .BYTE 05, 04, 03, 02, 01 .BYTE 03, 02, 01 I need ...
1
vote
3answers
1k views

Sort with unequal whitespace in first column

I need to sort this list by name, high temp and low temp: Kuala Lumpur 78 56 Seoul 85 66 Karachi 95 75 Tokyo 85 60 Lahore 85 75 Manila 90 85 I figured since whitespace is the delimiter for a column ...
1
vote
2answers
613 views

Sort lines based on a variable-width number at a fixed position

I'm trying to sort a file using the Sort command but its not working: The file contains lines like: photo1 photo11 photo12 photo13 photo17 photo18 photo19 photo2 photo22 photo23 photo25 photo26 ...
1
vote
2answers
161 views

sort and ls — why aren't capitalized letters sorted first?

I want a sorting like this, with capitalized letters before lowercase: -rw-r--r--. 1 0 0 183 2014-10-14 20:17 ./CHECKSUMS.md5 -rw-r--r--. 1 0 0 185 2014-10-14 20:17 ./CHECKSUMS.asc ...
1
vote
3answers
49 views

How can i get the process with the biggest pid?

How can I get the process with the biggest pid using ps?
1
vote
2answers
275 views

How batch mv files to folders created and named by modification date?

I am quite new to the terminal stuff and I just couldn't find any answer on the aforementioned subject. On my OS X, I have a folder with about 4000 pics that I'd like to move into folders that are ...
1
vote
2answers
258 views

How to remove duplicate entries from a file?

I have a comma-separated list of domain-names in a file; unfortunately there are duplicate entries for some domain-names. Is there a way to find and remove the duplicate entries from the file? The ...
1
vote
3answers
190 views

How to sort and join at the same time?

I have 2 files, one having 2 columns, another having 1 column. The second file is sorted using sort -u. Now the task is I need to join this column with the first column of the first file, which is not ...
1
vote
1answer
327 views

Sort -u Function Command Not Working

As you can see in the picture attached screen shot After I used the sort command to sort a VERY large wordlist file I then split them up using the Split command. From there I confirmed that the ...
1
vote
5answers
81 views

How to sort on two fields of numbers

I have a list of filename like so: epdb_0_0.pdb epdb_0_10.pdb epdb_0_11.pdb epdb_0_12.pdb epdb_0_13.pdb epdb_0_14.pdb epdb_0_15.pdb epdb_0_16.pdb epdb_0_17.pdb epdb_0_18.pdb epdb_0_19.pdb ...
1
vote
1answer
50 views

List the lines with the highest scores

I have the following problem concerning the sorting of a content of a file. I have a file called points.txt and it contains the following table of data: Jim:4 Tim:8 Lin:6 Tom:1 Esko:2 Jaska:5 Erkki:7 ...
1
vote
3answers
477 views

Reading a directory in shell script

I want to read a numbered directory which is under a path, into a variable in shell script. The paths are something like this: .../releases/R1/... .../releases/R2/... .../releases/R3/... Each time ...
1
vote
2answers
467 views

Deleting specific lines and duplicates from a 11gb wordlist text file

I have an 11gb wordlist file which is already sorted as each word is on its own line. I need to remove duplicates and lines starting from 077. I guess I need to run sed and sort -u together but I ...
1
vote
3answers
280 views

Numerically sorting files [duplicate]

Possible Duplicate: List files sorted numerically How can I sort this according to the number of last field? I tried with sort -t ' ' -k9,10n: -rw-r--r-- 1 root root 440 May 14 08:52 ...
1
vote
1answer
48 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
1answer
45 views

Removing duplicate lines after comparing first pattern and special pattern

I'm looking for code to removing duplicate lines after comparing the first tab-delimited pattern: Example : (↦ = tab) car ↦ ab ↦ 38/43 car ↦ ca ↦ 2/34 house ↦ ca ↦ 34/34 house ↦ d ↦ 2/3 house ↦ ht ↦ ...
1
vote
1answer
40 views

Numeric sort by the column values

For example I have some test file and want to sort it by the column values. After awk -F'[:,]' '{print $16}' test.json I get next output for the column 16: 123 457 68 11 939 11 345 9 199 ...
1
vote
2answers
82 views

How can I sort a .txt file by two columns?

Feb 7 domainserver dovecot[37495]: auth(default): od(tjones): lookup failed for user: tjones Above is a sample output of what I'd like to sort. I'd like to sort by date on the first column, but ...
1
vote
4answers
263 views

Why are sort options -c (check if sorted) and -o (write to output file) not compatiable

I am sorting a large number of files one after another. Using sort -o file file. The for loop halted midway and before restarting I want to use sort's -c option to speedup sorting. But it says that ...
1
vote
1answer
91 views

Sort aligned columns

I have a program which output looks like this # Status VAL1 VAL2 Description 1 some text 2.5 4.4 Some long other text 5 some text 2 14.5 2.0 Some long other ...
1
vote
3answers
2k views

strange problem: join: file 2 is not in sorted order

sort flash_int_list.txt|join finish_comm - > t1 join: file 2 is not in sorted order I have sorted flahs_int_list.txt but it still says file 2 is not in sorted order what is wrong ? the ...
1
vote
3answers
2k views

Script to show number of files (by file type) in a directory?

I want to show this kind of statistics about a particular directory: $ myscript.sh .c 34265 files .h 17866 files .cbl 1804 files .pco 389 files [...] Is there a tool that can do this? Here is my ...
1
vote
1answer
35 views

Sort and backup log4j files

I apologize for length of this question. It's difficult to explain, even though I was fluent in English, which I'm not ;) Not really sure where post this question, because it has java, log4j library ...
1
vote
1answer
39 views

Need to use grep and sort for matching records and display Y and N

Input file (contain column 1 with repeat value in number and second column may contain voice,email, tel, voice mail): 123,voice 123, tel 324,voice mail 345,email 123,email Output file with headers ...
1
vote
3answers
88 views

How to sort the filenames shown in grep command based on timestamp?

In the following command, how can I get the file names based on its timestamp $ grep "exit 0" a* a1.txt:+ exit 0 a2.txt:+ exit 0 a3.txt:+ exit 0 a4.txt:+ exit 0 a5.txt:+ exit 0 $ ls -latr ...
1
vote
1answer
67 views

`sort` disregards question mark [duplicate]

I need to sort a file based on names in the first column. Some of the names end in a question mark. sort persistently ignores this question mark during sorting: sort -k 1 -t , <<TEST a?,1 a,2 ...
1
vote
1answer
53 views

How to sort these lines?

I have this text: menu.overlap.x: -7 menu.overlap.y: 0 !! Menu settings menu.title.bg: Solid Flat menu.title.bg.color: #fce855 menu.title.bg.colorTo: #daa30b menu.title.bg.border.color: black ...
1
vote
1answer
57 views

Memory-efficient utility to return N first sorted values

I would like to implement a very popular MapReduce example using only existing programs operating in a UNIX way. The problem is to find N most frequent values in an enormous amount of data. The ...
1
vote
1answer
2k views

How to match 2 large file and print the difference in shell script

I have 2 files. File1 has 400k numerical records. e.g: 1 2 3 4 5 6 .. and so on File 2 also has 420k numerical records. e.g: 1 2 3 4 6 .. and so on Both these file are in unsorted manner. I want ...
1
vote
1answer
978 views

Sorting by one column then the

Say i have a output file with following: 010513 08:04 ROUTER1 192.168.1.1 68.130.5.10 HIT(1) 010513 08:04 ROUTER1 172.168.1.1 28.130.5.10 HIT(1) 010513 08:04 ROUTER1 122.168.1.1 ...
1
vote
4answers
42 views

Sort datetime string in 12-hour format

I have a log file with contents like this: 11-12-2014 - 03:03:59AM lat = 41.990516; lon = -93.430704<br> 11-12-2014 - 03:05:15AM lat = 41.001546; lon = -93.443352<br> 11-12-2014 - ...
1
vote
1answer
32 views

Different results OS X/Linux with “find PATH -mount \( -type f -o -type d \) -print0 | LC_ALL=C sort --zero-terminated > OUTPUT.txt”

this command is part of a script I use for comparing files: find test/ -mount \( -type f -o -type d \) -print0 \ | LC_ALL=C sort --zero-terminated > OUTPUT.txt // test/ is the PATH ...
1
vote
0answers
42 views

Characters not defined into iso14651_t1_pinyin are not sorted properly

when I try to sort characters not defined in iso14651_t1_pinyin, no sort happens, they are simply left in place. I would expect to see them sorted according to their codepoint. Is there a way I can ...
1
vote
3answers
298 views

another question with sort in bash [duplicate]

How can I ignore the space in "Kuala Lumpur" when sorting this list? I cheated it by tabbing the columns and sorted on the tab which gives me the right results but I would like to know how to deal ...
1
vote
2answers
67 views

Compare and print data from different text files to one in Shell

How can I compare and print data from different text files to one in Shell. I have captures NAS details of three different boxes using SSH, now I need to combine all the three text files to one file ...
0
votes
2answers
569 views

Sort a text file according to a character within a field

I have a file named : newfile which consist of the following data 1 AC BB CC 2 AB CC DD 3 CA BB CC 4 BE DD EE 5 BD AA AA I type the following command in bash to sort the data according to the ...
0
votes
1answer
119 views

Sort in Linux for column, keeping other values intact

NODE_154_length 847 2997 NODE_154_length 3283 4509 NODE_154_length 4672 5715 NODE_154_length 6977 7768 NODE_29_length 3790 4317 NODE_29_length 4356 4712 NODE_29_length 4356 4712 ...
0
votes
1answer
95 views

Why this sort command gives me an empty file? [duplicate]

prova1 is a file with some text. When I run this code prova1 become empty: sort prova1 > prova1 I know that to achieve the effect I can do: sort prova1 -o prova1 I would just know the reason ...
0
votes
1answer
5k views

How to sort by multiple columns? [duplicate]

I have a tab-separated file, and I want to sort it by its columns 9, 14, and 16. By this I mean that all rows that agree at column 9 should be sorted by column 14, and among these, those that also ...
0
votes
1answer
217 views

How to sort date: YYYY.MM.DD. HH:MM?

INPUT: b|2013.06.03. 18:47| a|2013.06.03. 13:15| c|2013.06.03. 13:53| needed OUTPUT: a|2013.06.03. 13:15| c|2013.06.03. 13:53| b|2013.06.03. 18:47| How can I sort the dates correctly in ...
0
votes
1answer
781 views

Sort a file based on 1 column [duplicate]

Possible Duplicate: how do you sort du output by size? I have a text file generated from the output of du --max-depth 1 -h > sizeOfHomeFolder.txt It's contents are in this format: $ ...
0
votes
1answer
37 views

Sort three columns? [closed]

sort -t $'\t' -k 1rn,1 -k 2,2rn -k 3f,4 listaprezzi 2050 900 bananas 5 1905 700 grapes 17 250 4000 oranges 10 230 9200 ...
0
votes
1answer
748 views

Sorting file by second column

How can I manipulate a two columns tab-separated text file by sorting by the first element of the second column (only if the first column element is the same)? Exemple: Input File 1 A 1-2 A ...
0
votes
1answer
77 views

How to perform custom sort

I have the following line in a file : [[0, [0, '1']], [1, [0, '2']], [2, [0, '3']], [3, [0, '4']]] [[0, [1, '5']], [1, [1, '6']], [2, [1, '7']], [3, [1, '8']]] [[0, [2, '9']], [1, [2, '10']], [2, ...
0
votes
3answers
505 views

Sorting IP address according to the second field in file

in my ksh script I need to add the following task ( OS - linux/solaris ) I have the following file more test.txt /etc/backup/app 172.1.120 172.110.120 /etc/backup/app 172.1.120.12 ...
0
votes
1answer
52 views

Merging CSV files without losing the header line

I need to merge two CSV files: datasorted1.csv and datasorted2.csv, but my headers keep getting sorted. head -n 1 datasorted1.csv datasorted2.csv > resultado.csv && tail -n +2 ...
0
votes
2answers
26 views

sort command in unix with numeric sort

I have file1 : "$lvl=57" "$lvl=20" "$lvl=48" "$lvl=17" "$lvl=58" file2 i want : "$lvl=17" "$lvl=20" "$lvl=48" "$lvl=57" "$lvl=58" Basically numerically sort of file1