If I use ls to print all the files of a folder, is there a way to sort using roman numerals?
I am thinking about a result like:
benjamin_I.wmv
benjamin_II.wmv
benjamin_II.wmv
benjamin_III.wmv
benjamin_IV.wmv
benjamin_V.wmv
benjamin_VI.wmv
benjamin_VII.wmv
benjamin_VIII.wmv
benjamin_IX.wmv
The roman numerals are always preceded by an underscore.
Egads... I'd translate the numbers from roman numerals into normal numbers, sort, then change them back.
...but beware of all the valid words that can be made from roman numerals:
These 3 Users Gave Thanks to Corona688 For This Post:
@centurion_13: arabic() is a function defined in Roman.pm module, to convert roman number to arabic (e.g.
That's what that Roman.pm module is made for.
$1 references what was captured in a most recent regex with parentheses.
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
The utility msort is in the Debian GNU/Linux repositories. It often makes life easy for complex sorting situations:
producing:
If you do not use Debian, see the msort home page as noted in the script.
Best wishes ... cheers, drl
PS. I had trouble with older versions of msort on 64-bit Debian (lenny), but the version of msort on the current stable edition (squeeze) seems to work correctly, as noted above.
Heyas
Just a little fun script (code block) i'd like to share for fun.
#/bin/bash
# roman.sh
#
# Function
#
num2roman() { # NUM
# Returns NUM in roman letters
#
input=$1 # input num
output="" # Clear output string
len=${#input} # Initial length to count down
... (9 Replies)
Hi Experts,
I have a filelist collected from another server , now want to sort the output using date/time stamp filed.
- Filed 6, 7,8 are showing the date/time/stamp.
Here is the input:
#----------------------------------------------------------------------
-rw------- 1 root ... (3 Replies)
Input file:
100%ABC2 3.44E-12 USA
A2M%H02579 0E0 UK
100%ABC2 5.34E-8 UK
100%ABC2 3.25E-12 USA
A2M%H02579 5E-45 UK
Output file:
100%ABC2 3.44E-12 USA
100%ABC2 3.25E-12 USA
100%ABC2 5.34E-8 UK
A2M%H02579 0E0 UK
A2M%H02579 5E-45 UK
Code try:
sort -k1,1 -g -k2 -r input.txt... (2 Replies)
Hello all -
I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Assoc.txt
CHR SNP BP A1 TEST NMISS OR STAT P
1 rs2980319 766985 A ADD 4154 1.024 0.1623 0.8711
1 rs2980319 766985 A AGECAT 4154 1.371 6.806 1.003e-11
1 ... (6 Replies)
Hi Guru's,
Before writing to this forum I have searched extensively on this forum about my problem.
I have to write a shell script which takes out only those file names from the given directory which contains only numbers. For example, In the given directory these files are present:
... (5 Replies)
I did a search but couldn't find a thread that seemed to answer this but my apologies if it has been answered before.
I have some text files and I need to remove any line that does not start with a number (0-9). In actuality every line like this starts with a 'T' (or 't') but there are a... (5 Replies)
I need help to get only the numerals from a string
Ex :
var1=Nightfox has 2 red apple(s)
I need to cut only the numeral 2 and move it to a variable.
var2=`$var1 | cut -c 14`
the cut by character doesnt work, how to get only the numeral ? (2 Replies)
Hi!!!
i have two files "tushar20090429200000.txt" and "tushar_err20090429200000.txt"
The numeric part here is date and time.
So this part of file keeps changing after every hour.
I want to extract the numeric part from the both file names and compare them whether they are equal or not.
... (4 Replies)