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

learn more… | top users | synonyms

3
votes
2answers
407 views

sort a file based on length of the column/row

I need to sort a file based on the number of chars in the first column. I have no idea on how to go about this. (On Linux, so sed/awk/sort is available). An example: .abs is bla bla 12 .abc is bla ...
1
vote
2answers
214 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 ?)
2
votes
2answers
480 views

Reorder folders on FAT32 drive

My car can read MP3 files from a FAT32 flash drive. I have a folder for each artist on the drive, then MP3 files in those folders. However the car does not read the folders alphabetically, but by the ...
0
votes
1answer
115 views

Remove repeated words with suffix in a file

I have a list of records in a file as in below example word_word1 word_word1_acc word_word2_acc word_word3_acc word_word4 I need to remove only word_word1_acc line in the file as it is only a ...
1
vote
2answers
468 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 ...
2
votes
1answer
921 views

How can I list my `at` jobs by date?

I am using atq command, but I need to list my at jobs by date. How is that possible ?
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 ...
6
votes
1answer
1k views

comm: file is not in sorted order

I used comm to compare two sorted files. Each line in these files are positive integer numbers. But the results show comm: file 1 is not in sorted order comm: file 2 is not in sorted order How ...
5
votes
1answer
197 views

Alphabetizing names in `ls` alias with .files not intermingled

I am currently using the following ls alias: alias ls='ls -alhGkpsq --color=auto'. This results in following directory listing. [03:35] bryson@brys ~ :$ ls total 48K 4.0K drwx------ 4 bryson 4.0K ...
14
votes
2answers
12k 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
4k views

The simplest method to count lines matching specific patterns, including '0' if line is not found?

I have very big logs (several gigabytes per day), that can (but do not need to) contain specific lines. I have to count the number of occurences of every one of these lines on a daily basis. I have a ...
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 ...
5
votes
4answers
538 views

How to shift filename numbers without collisions?

Consider this list of files: $ touch index-{1,2,3,4,5,6,7,8,9}.txt If I want to shift them down so they start at zero, it's relatively easy: $ rename --verbose 's/^index-([1-9])\.txt$/$1/; ...
4
votes
1answer
2k views

How to find out common elements between two files?

For an example, I have 2 files having following info: File #1: 12 13 14 15 File #2: 12 1 13 2 14 2 15 6 16 7 17 8 Output File: 1 2 2 6 In the output file, I want only the second column ...
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 ...
11
votes
3answers
3k 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 ...
3
votes
1answer
2k views

File size limit exceeded in bash [closed]

I have tried this shell script on a SUSE 10 server, kernel 2.6.16.60, ext3 filesystem. The script has a line like this: cat file | awk '{print $1" "$2" "$3}' | sort -n > result The file's size ...
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: $ ...
3
votes
4answers
768 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, ...
5
votes
3answers
3k views

What's the default order of Linux sort?

For a long period I thought the default behavior of the sort program was using ASCII order. However, when I input the following lines into sort without any arguments: # @ I got: @ # But ...
10
votes
3answers
4k views

How to sort the string which combined with string + numeric using bash script?

This is the data what I want to sort. But sort treats the numeric to string, the data it no sorted as I expected. /home/files/profile1 /home/files/profile10 /home/files/profile11 ...
3
votes
2answers
870 views

Using sort with alphanumeric filenames

I'm sorting the results of a find command which finds all of the files in the current directory: find . -maxdepth 1 -type f -iname "*.flac" | sort What I'm expecting is a list like this: ./Track ...
2
votes
2answers
2k views

Sort by regular expressions

I've got a set of POSIX regular expressions* ^BEGIN:VCARD\r$ ^VERSION[^A-Z] ^FN[^A-Z] ^N[^A-Z] ^NICKNAME[^A-Z] ^EMAIL[^A-Z] ^X-\([A-Z-]*\) ^TEL[^A-Z] ^ADR[^A-Z] ^ORG[^A-Z] ^TITLE[^A-Z] ^BDAY[^A-Z] ...
9
votes
4answers
5k views

How do I make ls sort underscore characters first?

I like being able to name files and directories with an underscore prefix if it's something I want to keep separate from other files and directories at the same level. On Windows and Mac, for example, ...
4
votes
6answers
7k views

Get text-file word occurrence count of all words & print output sorted

I had a command which would work through a text file, count all the occurrences of the words and print it out like this: remy@box $˜ magic-command-i-forgot | with grep | and awk | sort ./textfile.txt ...
1
vote
3answers
282 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 ...
7
votes
4answers
217 views

Sort fields inline

I'm trying to sort within a line of input over an unknown number of fields: Input: ab bc bc ab cd ef bc bc cd ef cd bc ab ef ab bc cd gh Output: ab bc ab bc bc cd ef bc cd ef ab cb cd ab bc cd ...
5
votes
4answers
843 views

For each subfolder, sort files by name and rename them to sequential padded numbers (regardless of extension)

I have the following directory structure: . ├── event-a │   ├── album-a │   │   ├── a.jpg │   │   └── x.png │   └── album-b │   ├── a.jpg │   ├── x.png │   └── y.gif └── event-b ├── ...
0
votes
1answer
113 views

How to sort a Diary?

Diary has entries with month and day, no years, in the format %D_%M.tex but index in wrong order because of wrong sorting and poor filename -format. How should I call my Diary -entries to get them ...
3
votes
3answers
2k views

How to reorder a large number of columns?

I'm looking for a pipeable one-liner to reorder a large number of columns (where manually entering the column numbers in e.g. an awk command such as awk '{print $3,$2,$1}' is not feasible). The order ...
11
votes
2answers
3k views

Why does ls sorting ignore non-alphanumeric characters?

When sorting file names, ls ignores characters like -,_. I expected it to use those characters in sorting as well. An example: touch a1 a2 a-1 a-2 a_1 a_2 a.1 a.2 a,1 a,2 Now display these files ...
2
votes
2answers
698 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 ...
6
votes
3answers
783 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 ...
6
votes
2answers
442 views

sort every field numerically, varying field counts

I'm trying to sort some data using sort. I noticed it was sorting by digit rather than number, so I added the -n flag. It then seemingly only numerically sorts on the first field though. Breaking it ...
4
votes
1answer
817 views

Linux sort second last column

I would like know how to sort the second last column ? It has the word "days=" in front of the number. I'm able to get the column with awk '{print $(NF-1)}', but sorting is wrong. 457000 ...
14
votes
4answers
14k views

Sorting the output of “find”?

I need to be able to alphabetically sort the output of find before piping it to a command. Entering | sort | between didn't work, so what could I do? find folder1 folder2 -name "*.txt" -print0 | ...
3
votes
1answer
3k views

Linux sort last column

I'm running a script (that I have no control of) to get the following output. I want to sort by the last(3rd) column. Each column is separate by spaces, and the 2nd column includes spaces/symbols. ...
15
votes
7answers
11k views

List files sorted numerically

I have a bunch of files from log1 to log164. I'm trying to LIST the directory (sorted) in a UNIX terminal but the sort functions are only providing the format like this: home:logs Home$ ls -1 | sort ...
4
votes
1answer
413 views

Renaming files from bash in linux

There is a bunch of files of the following format hh-mm-ss.png where hh, mm, ss are hour, minute and second. How can I rename all these files in the directory in a sequential way from 1.png til n.png ...
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 ...
4
votes
1answer
850 views

How do get unix sort to sort in same order as Java (by unicode value)

I shell out sorting to the unix sort command in a Java program I've written. However I am having problems arising from Java's string comparison behaving differently than the comparisons done by sort. ...
6
votes
7answers
2k views

How to sort (by whatever key) BibTex entries in `.bib` file?

I work with LaTeX and do versioning with Git. For bibliography management I use Mendeley. The problem is that each time Mendeley synchronizes it's .bib exports, they are in different order, what ...
4
votes
3answers
5k views

Get lines with maximum values in the column using awk, uniq and sort

I have a file with next format 2011-12-01 user1 access1 2011-12-01 user1 access2 2011-12-01 user2 access2 2011-12-01 user4 access2 2011-12-02 user1 access1 2012-01-01 user3 access1 2012-01-01 user4 ...
11
votes
2answers
3k 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 ...
2
votes
2answers
2k views

Issues of using sort and comm

I was trying to find the intersection of two plain data files, and found from a previous post that it can be done through comm -12 <(sort test1.list) < (sort test2.list) It seems to me that ...
6
votes
4answers
411 views

Fastest way to determine if two sorted lists contain unique elements

I have two sorted files A and B where the size of A is much greater than B, e.g. A is 100GB while B is 50MB. I want to quickly determine if there are any lines in B that are contained in A, stopping ...
6
votes
2answers
643 views

How would I sort these directory names numerically?

I'm aware that I can somehow sort this output numerically (so cpu1/ follows cpu0/) ... I could probably get something to work eventually by splitting up the string various ways with awk, but is there ...
11
votes
5answers
4k views

case-insensitive search of duplicate file-names

I there a way to find all files in a directory with duplicate filenames, regardless of the casing (upper-case and/or lower-case)?
4
votes
2answers
776 views

Sort behaves strangely on case sensitive sorting

Sort is sorting differently than I would expect. I have this file, call it text.txt: a 1 A 1 a 11 (the space is always one \t) I want to sort them alphabetically by the first column. ...
2
votes
2answers
217 views

Move one file at a time based from specific number in the files

Based from this question, The HTML files date format has been changed. All of the HTML files have the date such like below: 20110730dateishere dateishere is intentionally added by me in the files, ...