Is it possible to reproduce the "sort by name" windows option?
You know, Windows doesn't seem to have the magical ability to consistently handle inconsistently named files either. I'm always running into corners where it guesses wrong too.
Could you not just rename the inconsistent files and solve the problem permanently?
I don't know how to do it, but sorting with two keys should work...
I'm not sure what you mean by that.
I can think of ways that may end up working with the filenames you've posted, but it will choke on lots of other inconsistent filenames. A general solution would need the ability to actually analyze the names for the pattern, and figure out what to do with exceptions...
All I have now is a way of sorting files IF the folder contains only one name pattern.
Sure I can provide user input to guide the sorting process, but I'd prefer not to do it.
Why sorting using two keys isn't a good idea?
Getting the first character and use it to sort means I can sort files with a two steps process.
(this means file names differs from the first character: 03_XXX, 10_XXX, a_XXX... But, as 99,5% of files I need to sort are like that, this could work...)
Thanks a lot for your reply!
I came to the very same solution!
Now, I need something more...
is there a way of dinamically add keys to sort?
I mean:
I can count the number of columns in a file. I need, then, to sort that file using:
Quote:
sort -k1,1 ...... -kN,N
where N is the number of columns.
Is there a way, maybe a while loop, to add keys to sort command?
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
This solution-comparison will not be useful if one must use busybox or similar, but for people who can acquire and make available codes, the msort solution seems simple and produces a result that appeals to me:
producing:
See link in previous post for some details about msort.
Personally, I think I would seriously consider renaming files consistently (possibly assisted by symbolic links) and be done with it.
I want to sort a file which contains alphanumeric string.
bash-3.00$ cat abc
mtng1so
mtng2so
mtng11so
mtng9so
mtng23so
mtng7so
hstg2so
hstg9so
hstg1so
hstg11so
hstg13so
bash-3.00$
Want output like this, using one liner.
hstg1so (1 Reply)
Below is the part of contents of a file
cat outputFile.txt
:APP-MS-service_monitoring-118054-DiskFilling-S
Description=Disk is getting filled.
If Condition=If Event/Log Level(ANY) and matching substring "DiskFilling" Log: xx.x.x..xx.: 4 days 1:33:54.42
Date and time=03-18-2013... (2 Replies)
Hello,
I have a large database of words and would like them sorted in reverse order i.e. from the end up.
An example will make this clear:
I have tried to write a program in Perl which basically takes the string from the end and tries to sort from that end but it does not seem... (5 Replies)
Hi All,
I want sort following files in ascending order.
exp_installer_CC4160-file10.dmp
exp_installer_CC4160-file11.dmp
exp_installer_CC4160-file12.dmp
exp_installer_CC4160-file13.dmp... (3 Replies)
I have a vector of strings that contain a list of channels like this:
101,99,22HD,432,300HD
I have tried using the sort routine like this:
sort(mychans.begin(),mychans.end());
For some reason my channels are not being sorted at all. I was hoping someone might have some input that might... (2 Replies)
Hi guys, I'm new to this forum and I'm not a UNIX expert. I can't figure out this certain problem i'm having:
I need to sort some words, some of the words are annotations (enclosed within < and >). I need to have them sorted alphabetically with all non-alphanumeric characters up front. For... (2 Replies)
Hi ,
I have a requirement where one column have to be sorted (delimiter is pipe)
for eg:
My input filed is as below
1|FIAT|0010103|23011|01/01/2000|31/12/9999|1.15
2|232|613|1
2|234|743|1
2|234|793|1
2|234|893|1
1|FIAT|0010103|23012|01/01/2000|31/12/9999|1.15
2|230|006|0
2|230|106|0... (9 Replies)
Hi,
I trying to find the solution for writing the programming in unix by shell programming for sorting thr string in alphabetical order.
I getting diffculty in that ,, so i want to find out the solution for that
Please do needful
Thanks
Bhagyesh (1 Reply)