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

learn more… | top users | synonyms

1
vote
3answers
47 views

How can i get the process with the biggest pid?

How can I get the process with the biggest pid using ps?
11
votes
3answers
712 views

Sorting data faster approach

I need to sort a bed file randomly 10000 times and take the top 1000 rows each time. Currently, I am using the following code: for i in {1..100}; do for j in {1..100}; do sort -R ...
8
votes
2answers
313 views

sort by hex value

Using coreutils sort, how can I sort numerically by a hexadecimal value (field)? I was expecting something along the lines of sort -k3,3x file_to_sort however, such an x does not exist. Edit: ...
-1
votes
1answer
28 views

How do I sort the signal buses with bits in ascending order?

I am trying to sort a file with signal buses. I am looking for result where the bits are in ascending order -- 2 followed by 3 and not 20. cat file1 |sort file1 cls_16_snap[2] cls_16_snap[20] ...
2
votes
3answers
79 views

Get the last minute dated lines from list

If I have an input file with a list of users and their dates they were last signed in, how can I select with a sort | awk function the last minute lines? The dates are written in a +%H:%M:%S format. ...
2
votes
1answer
45 views

sort based on column

10 awhdk; 14 hjoeow; 2 kdkld; 4 jkjdksl How to sort this based on column one (i.e the count) ? I'd want to get this output : 14 hjoeow;10 awhdk;4 jkjdksl;2 kdkld I need both the columns to be ...
2
votes
2answers
122 views

How to print top five highest numbers from a column?

I have a text file with four columns. I need to read till end of file and print the highest number from column3 (top 5 values) along with column 1. input.txt xm|340034177|ref|RT_235820.1| 139697 ...
1
vote
2answers
115 views

Sort files into directories named by prefix of file

I have a bunch of files like this 5830_1.png 5830_2.png 5830_3.png 5831_1.png 5832_1.png 5832_2.png I'd like to sort these files all into directories that take the prefix of the file name as the ...
1
vote
1answer
66 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 ...
2
votes
2answers
191 views

Tool for viewing top N items in stream

I'm looking for an existing Linux command-line tools that can accomplish the following: Consider there is an input stream /dev/inputstream which spews an infinite stream of data that looks like this: ...
3
votes
1answer
293 views

Fastest `uniq` tool in linux

I have large text file (1.5 G), I want to know what the fastest and more reliable tool in linux is. I usualy use: awk '!x[$0]++' file.txt But when I use htop command I see my memory usage is ...
0
votes
2answers
42 views

Sorting by Last Name in the Scond Column

I'm trying to sort a file that has entries that look like so: Essie | Vaill | 14225 Hancock Dr | Anchorage | AK | 99515 907-345-0962 Please note the "|" stand for tabs of ...
2
votes
2answers
107 views

Check if a drive has been Zeroed with xxd and uniq?

I'm looking for a way to check if the entire binary contents of a USB device are purely 0s. I'm trying this command: sudo xxd /dev/sdb | uniq but it has no output and just runs forever. I've ...
6
votes
1answer
156 views

How to specify additional parameters for GNU sort's --compress-program option?

sort --compress-program=/bin/gzip works fine, but how can I pass options down to the compression programm (e.g. --best or --fast)? sort --compress-program=/bin/gzip\ --best failes with the error ...
2
votes
3answers
374 views

How can I get the last line number of unique commands when grepping my history file?

I rely on my history file for previous commands, especially ones that are long with many parameters. Once I find the command and its line number(nn) I use !nn to run it. I prefer to see the full ...
2
votes
7answers
1k 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 ...
2
votes
1answer
6k views

Sort data in descending order of first column, for equal values, use second column in ascending order

Allow me to clarify: Assume I have some keywords with frequency of their usage: 12 Hi 7 Hash 7 C++ 9 Superuser 17 Stackoverflow 9 LaTeX 42 Life 9 Ubuntu What I want, is to sort this data ...
2
votes
1answer
63 views

How to use gnu sort to sort lines with field delimiter present only on some lines

In my .vimrc I list my vundle bundles like so: cat ~/.vimrc ... Bundle 'Raimondi/delimitMate' Bundle 'kien/ctrlp.vim' Bundle 'matchit.zip' Bundle 'upAndDown' Bundle 'rking/ag.vim' ... Now, I would ...
6
votes
2answers
163 views

Sorting with Perl respecting Locale Settings

Following data needs to be sorted respecting the locale sort order: wird sin wär pêche war Über Uber péché peach There was nor problem by using sort $ sort < data peach pêche péché sin Uber ...
3
votes
2answers
2k views

How to sort big files?

I have a PC with Intel(R) Pentium(R) CPU G640 @ 2.80GHz and 8 GByte RAM. Installed Scientific Linux 6.5 on it with EXT3 filesystem. Q: What is the fastest way I can do a "sort -u list.txt -o ...
6
votes
1answer
86 views

biggest possible number for sort -n

How to determine the "biggest number" so that sort -n will always put it at the end? I'm thinking of something along Inf in some languages but I'm not sure if anything like this exists for sort. ...
6
votes
2answers
2k views

Counting number of times each IP address appears in log file

I have a file in the format as follows: $ cat file.txt 27.33.65.2 27.33.65.2 58.161.137.7 121.50.198.5 184.173.187.1 184.173.187.1 184.173.187.1 What's the best way to parse the file file.txt into ...
0
votes
2answers
483 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 ...
3
votes
4answers
557 views

How to sort a list of files by time, given only the filenames

Given a list of file names, how can I sort it by file modification time? The resulting output needs to look exactly like the input with the exception that the data has been sorted accordingly. Here ...
2
votes
3answers
1k views

How to show CPU time for processes via top without 'root' procs

Okay, So I've been attempting this for about three hours now without success. How do you search/display/use the top command (or ps command if it works...) to output a list of all procs, sorted by CPU ...
5
votes
2answers
95 views

Sort one column only, keeping remaining columns untouched

How to (numerically) sort a specific column in a text file, without affecting other columns (irrespective of whether they are sorted or unsorted)? On other threads I found -s argument, but it does ...
0
votes
1answer
110 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 ...
2
votes
3answers
30 views

Move line from output to the front of output or custom reordering

I have a command find "$PWD" -name __openerp__.py|awk -F/ -vOFS=/ 'NF-=2'|sort -u and I want to take a certain line containing /web/addons and push it to the front of output then do the same with ...
1
vote
1answer
49 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
56 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 ...
4
votes
3answers
334 views

Sort all directories based on their size

I'd like to sort all the directories/files in a specific directory based on their size (using du -sh "name"). I need to apply this command to all directories in my location, then sort them based on ...
2
votes
2answers
764 views

Sort based on the third column

I'm facing a huge 4-columns file. I'd like to display the sorted file in stdout based on its 3rd column: cat myFile | sort -u -k3 Is that enough to perform the trick?
3
votes
3answers
344 views

Print unique of who command

I want to show the online users using the who command but I want to have a unique output and not show any duplicates. I piped the output into awk but I am not very familiar with that, is this the ...
0
votes
1answer
71 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, ...
4
votes
1answer
243 views

How can I find the sort order for ls with my locale?

I was using ls -l on a directory, and was surprised that spaces and underscores were ignored for the sort order. For example, $ echo $LANG en_AU.UTF-8 $ ls -l total 0 -rw-r--r-- 1 sparhawk sparhawk 0 ...
1
vote
1answer
48 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 ...
2
votes
1answer
100 views

Sort doesn't use natural order

I have used uniq -c and sort extensively on other machines, and it always worked very well. Now, on my new Ubuntu (13.04) machine, I end up with a weird ordering: % cat queries.log | grep INSERT | ...
5
votes
5answers
378 views

Sorting blocks of lines

I have a file that contains 4n lines. Here is an excerpt from it containing 8 lines 6115 8.88443 6116 6.61875 6118 16.5949 6117 19.4129 6116 6.619 6117 16.5979 6118 19.4111 6115 8.88433 What I ...
10
votes
4answers
622 views

Shuffle file randomly with some additional constraints

I have a huge music playlist and, while some artists have many albums, others have just one song. I wanted to sort the playlist so the same artist won't play twice in a row, or his songs won't end up ...
0
votes
1answer
93 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 ...
2
votes
2answers
99 views

When do `sort -k 2,3b` and `sort -k 2,3` differ?

The POSIX description of the -b flag for the sort command is Ignore leading characters when determining the starting and ending positions of a restricted sort key. I can understand the use for ...
-1
votes
1answer
155 views

Select a range of files from directory structure /year/month/date.db

I have databases stored in the directory structure year/month/date.db an example would be db/2013/10/15.db I need to be able to select a range of these with a script ("dbSelect ...
26
votes
2answers
792 views

Why is sort -o useful?

UNIX philosophy says: do one thing and do it well. Make programs that handle text, because that is a universal interface. The sort command, at least GNU sort, has an -o option to output to a file ...
1
vote
4answers
240 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 ...
0
votes
1answer
99 views

What option(s) would you use to sort a file named foo in place, that is replacing the original file with the sorted version? [duplicate]

I have this homework question. I looked at the man page for sort and I believe the answer is -o, --output=FILE Is that correct? It is a Fedora server. We're supposed to look on man pages, if there ...
6
votes
4answers
966 views

uniq a csv file ignoring a column, awk maybe?

Given this file (annotations are not part of file, but form part of explanation)... x,a,001,b,c,d,y x,a,002,b,c,e,yy x,bb,003,b,d,e,y x,c,004,b,d,e,y x,c,005,b,d,e,y # nb - dupe of row 4 ...
4
votes
1answer
77 views

Help with the sort command (numeric)

I have this output I'd like to sort numerically by port (starting at the 35th column): tcp 0 0 192.168.0.210:110 0.0.0.0:* LISTEN 3385/dovecot tcp 0 0 ...
2
votes
2answers
1k views

Any tricks to speed up sort?

For example for bzip there is pbzip, a parallel version of bzip. Is there any such parallelization tools for sort to improve performance?
2
votes
3answers
2k views

How is it possible to sort ps command's CPU field?

I'm trying to make a small command that will find the processes that use the most CPU power. Firstly, I use ps aux > file.txt and then cut -c 16-20 file.txt | sort -n | tail -5. The result I get ...
0
votes
3answers
112 views

selecting rows that have the same value [closed]

I have a problem in selecting rows that have the same value. My data is too huge to go row by row to do that. I want you guys to let me know scripts that can perform this. My data looks like as ...