Tagged Questions
0
votes
1answer
38 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
78 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
36 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
74 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
50 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 ...
4
votes
2answers
226 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
288 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
628 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
272 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
251 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
136 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
3k 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 ...
20
votes
7answers
22k 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
530 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
682 views
unix sort algorithm implementation
What sorting algorithm(s) is/are used in the unix sort command? Insertion/quicksort/etc.?
0
votes
3answers
783 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 , ...
20
votes
10answers
13k 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
3k 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 ...
14
votes
2answers
21k 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 ...