0
votes
1answer
27 views

How to Sort in Unix using a specific location

Hi I have a large text file that I want to sort using a specific location (e.g. 6-12 characters) Ex. Input: 12345222 ABC DEG123456 AAA BBB 12345111VABCGDEG123456 AAA BBB ...
4
votes
2answers
203 views

Linux command line / Move files filtered by lexicographic order

I have some files in a directory that are named IMG_0001.jpg ... IMG_9999.jpg. I want to move to another directory the files that lexicographically have a name greater than IMG_9431.jpg How can I do ...
1
vote
0answers
33 views

Reordering file lines like other file (Unix)

Is there a tool (or option for sort) which will re-order lines of a file so that they are ordered like a key in another file? For example, I have a data file: T01F01475558 30 T01F022B3A17 31 ...
0
votes
1answer
221 views

sort tab delimited text fields involving spaces

I am having difficulty with the Unix sort command when tab delimited fields are introduced. If a file test.txt contains: Hello (2) Hello (1) Hello applying a sort: sort test.txt produces the ...
0
votes
1answer
623 views

UNIX command to sort the file by the following words, from major sort key to minor sort key: word 3, word 1, word 4

Need help with the UNIX command below to sort the file by the following words, from major sort key to minor sort key: word 3, word 1, word 4. (words are separated by white spaces) sort -t -k3 -k1 ...
5
votes
1answer
121 views

Merge sorted lists

I have a few .txt files (in the same directory) that look like this: 123 carrot 50 apple 13 tomato 5 potato 2 pear and 100 carrot 10 apple 3 tomato 2 potato ...
2
votes
1answer
47 views

Sorting a list of files

Maybe am missing something but how do i sort in a descending order a list with this naming B7 B40 B41 B42 B8 B43 B20 B45 B53 B47 B48 B5 B6 sort -n does not sort the way i would like B5 B6 B7 and ...
0
votes
2answers
172 views

How do I sort command-line output?

I'm trying to use du to sort the output by filesize, but it doesn't looks like there's an option for that. Can I pipe it into another command to handle the sorting?
3
votes
1answer
77 views

Bug in sort or misunderstanding

Suppose I have this file b 10 foo a 10 bar a 2 bar I want to sort by the third colum, alphabetically. In case of ties, I want to sort by the second column, numerically. In the man page for the unix ...
5
votes
3answers
746 views

How to do custom sorting using unix sort?

I'm using unix sort to sort a comma delimited file with multiple columns. Thus far, this has worked perfectly for sorting the data either numerically or in alphabetical order: Example file before any ...
0
votes
4answers
1k views

Reverse order using command

Is there a way i use the ps --sort option on a linux to display the processes in reverse order based on the process ID or is there another command i can use for this?
7
votes
4answers
3k views

Sorting numerically in a comma-delimited file with Unix

I've got a comma-separated file that looks like this: 100,00869184 6492,8361 1234,31 200,04071 I want to use sort to sort this file numerically by the first column only. Desired Result: ...
3
votes
2answers
483 views

Unix sort keys cause performance problems

My data: It's a 71 MB file with 1.5 million rows. It has 6 fields All six fields combine to form a unique key - so that's what I need to sort on. Sort statement: sort -t ',' -k1,1 -k2,2 -k3,3 ...
0
votes
1answer
469 views

Solaris + sorting file according to date and time by sort command

I have along list that created in /var/tmp/file.txt from some script (in Solaris machine) the following list have 4 fields please advice how to sort the list according to the following TIMESTAMP ( by ...
2
votes
1answer
223 views

Sorting a checksums file by file name

I'm trying to sort the output of the md5sum program by file name, numerically (that is, file names all match log-\d+\.txt). I tried sort -g "-t " -k 2 CHECKSUMS but it sorts by checksum. Using ...
1
vote
1answer
4k views

Can I use unix sort to sort a file on multiple keys of different types (mix of strings and numbers)?

I have a delimited text file of multiple columns some of which are text and some of which are numbers. I would like to sort on multiple fields, wich span both text and numerical fields. While -n ...
35
votes
12answers
45k views

Unix/Linux find and sort by date modified

How can I do a simple find which would order the results by most recently modified? Here is the current find I am using (I am doing a shell escape in PHP, so that is the reasoning for the variables): ...
0
votes
1answer
895 views

GNU sort and git blame

Today I thought I was doing a simple operation: git blame file | sort -k 3 To get all the lines of file sorted by the date on which they were last changed. Unfortunately it doesn't seem to be ...
4
votes
2answers
1k views

unix sort algorithm implementation

What sorting algorithm(s) is/are used in the unix sort command? Insertion/quicksort/etc.?
0
votes
3answers
1k views

Sorting is not consistent using the Unix command 'sort'

I'm running the command: zcat [File] | sed "1d" | sort -t $'\xE7' -k [field to be sorted] > [file].sorted When I run this on File A, sorting on field 1, I get the following result: 11622400 , ...
32
votes
8answers
21k views

Unix: ls, how to sort first directories then files etc

I would like to use ls command to first show direcotries and then files. I tried ls -la | sort -k 1 But I got a wrong order.
10
votes
6answers
5k views

Sorting human readable file sizes

How can I sort a list using a human-readable file-size sort, numerical sort that takes size identifier (G,M,K) into account? Can I sort "du -sh" output for example? Problem: Consider the problem of ...
17
votes
2answers
43k views

How to UNIX sort by one column only?

I know that the -k option for the Unix sort allow us to sort by a specific column and all of the following. For instance, given the input file: 2 3 2 2 1 2 2 1 1 1 Using sort -n -k 1, I get an ...