2
votes
1answer
43 views

Is there a way around broken pipe?

I have a directory with a large number of files. ./I_am_a_dir_with_many_subdirs/ Within a script I'd like to find all subdirs in it, to sort them and to output to a bash array. So, I do: ...
0
votes
0answers
25 views

I'm trying to list size of folders plus selected files on a portable disk

For the purpose of finding the location of my data among many portable disks, I'm trying to create plaintext lists of the contents of all folders and files of certain extensions and sort them by size. ...
1
vote
1answer
154 views

In bash, what is a “general” and “string” numeric value when sorting?

According to "man sort" there are two ways to sort numerically: -g, --general-numeric-sort compare according to general numerical value and -n, --numeric-sort compare ...
3
votes
2answers
63 views

Sort files with grep

I have a few hundreds of output files, of which some contain error messages. Lets say I want to automatically put all files containing the string "ERROR_1" in a "subfolder_1", and the rest in a second ...
1
vote
1answer
113 views

Sort lexicographically in bash

I want data to be sorted in the way Python sorts it, comparing ASCII values. But sort command seems too clever for that. Take a look. Since '.' < '9': $ sort . 9 ^D . 9 $ sort 1. 19 ^D 1. 19 ...
2
votes
3answers
227 views

weird filename sorting (bash, ls, sort)

Good day, everyone. I'm trying to feed my music to mplayer, like this: mplayer *, but getting wrong track order. Here's what I get with ls (as well as ls -1, ls -1 | sort), note the order of the ...
0
votes
1answer
419 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 ...
0
votes
5answers
1k views

Using find command to list top 5 image files by size

All, I want to list the top 5 image files (png,jpg) in a given folder.What's the best approach? I'm using the following currently but it doesn't give the right output: find . \( -iname \*.png -o ...
2
votes
1answer
183 views

Why is sort -k5nr not a syntax error?

$ ls -l | sort -k 5 -n -r $ ls -l | sort -k5nr I find out these two command generate the same output. But I don't understand why I can combine 5 with n? Why not a syntax error? edit: $ ls -l | cut ...
3
votes
2answers
328 views

How to reorder folders? (as displayed in `ls -U`)

I've got a number of unordered folders on a memory stick, which my car stereo shows in order of their real position on the stick (i.e. same as ls -U) What's the easiest way of physically reordering ...
3
votes
1answer
383 views

sort by word length in Nth column

I've got a column file like this: 1 1 1 AKSDFJADFKASDJFAK 2 1 1 ADKLCJASDLKCJDLACKADCJLKDACJADS 3 1 2 AKLJDFHALKDJFHLKJSDKSDFHAKJFDHAKFHJAKFJ And I would like to sort the entries by the fourth ...
1
vote
2answers
413 views

Sort multiple files with bash

I have a question that involves the bash scripting language. I have multiple directories /studentName /studentMail /studentNumber In each of these directories is a file name.txt, mail.txt, ...
0
votes
4answers
299 views

need advise on using sort command in Linux

How to sort a file using sort command.. I would like to sort the file based on 2nd field which is seperated by "," as a delimiter Ex: filename1, 465, output_file1, filename2, 300, output_file2, ...
25
votes
7answers
19k 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.
14
votes
5answers
13k views

In bash, how to sort strings with numbers in them?

If I have these files in a directory cwcch10.pdf cwcch11.pdf cwcch12.pdf cwcch13.pdf cwcch14.pdf cwcch15.pdf cwcch16.pdf cwcch17.pdf cwcch18.pdf cwcch1.pdf cwcch2.pdf cwcch3.pdf cwcch4.pdf cwcch5.pdf ...