Sponsored Content
Full Discussion: Sort roman numerals
Top Forums Shell Programming and Scripting Sort roman numerals Post 302508106 by mirni on Friday 25th of March 2011 09:46:25 PM
Old 03-25-2011
Your best bet is probably perl's 'Roman' module.
Download Roman.pm from CPAN here: http://search.cpan.org/~chorny/Roman-1.23/lib/Roman.pm
copy it into /usr/lib/perl5/site_perl/5.8.8/ (adjust to your perl version).

Create a perl script sortRoman.pl:

Code:
#!/usr/bin/perl -w

use Roman; 

sub romanSort {  #custom sorting definition
    $a =~ /^.*_([MDCLXVI]+)\..*/;  #capture all roman numerals after underscore
    $aRom = arabic($1);   #convert captured roman number to arabic (e.g. XIV --> 14 )
    $b =~ /^.*_([MDCLXVI]+)\..*/;   #repeat with second input

    $aRom <=> arabic($1);  #numeric comparison between the converted numbers
}

@data = (<>);  #slurp the whole input into one array

print sort romanSort @data;  #print sorted array using custom routine romanSort

make it executable
Code:
chmod 754 sortRoman.pl

and try it out:
Code:
$ cat testdata
b_II.wmv
b_III.wmv
b_IX.wmv
b_IV.wmv
b_VI.wmv
b_V.wmv
b_VII.wmv
b_CXLIV.wmv
b_CXIV.wmv
b_CXII.wmv
A_B_XIV.wmv

$ ./sortRoman.pl testdata
b_II.wmv
b_III.wmv
b_IV.wmv
b_V.wmv
b_VI.wmv
b_VII.wmv
b_IX.wmv
A_B_XIV.wmv
b_CXII.wmv
b_CXIV.wmv
b_CXLIV.wmv


Last edited by mirni; 03-28-2011 at 08:07 AM..
These 2 Users Gave Thanks to mirni For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extracting only numerals from string.

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)
Discussion started by: tushar_tus
4 Replies

2. UNIX for Dummies Questions & Answers

Using CUT command to get only numerals from a string

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)
Discussion started by: happyrain
2 Replies

3. UNIX for Dummies Questions & Answers

Deleting lines starting with spaces then non-numerals

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)
Discussion started by: skray
5 Replies

4. Shell Programming and Scripting

How to select only those file names whose name contains only numerals.

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)
Discussion started by: spranm
5 Replies

5. Shell Programming and Scripting

Sorting with header and mixed numerals (scientific and decimal) | awk

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)
Discussion started by: genehunter
6 Replies

6. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

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)
Discussion started by: pankaj80
3 Replies

7. Shell Programming and Scripting

Help with sort word and general numeric sort at the same time

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)
Discussion started by: perl_beginner
2 Replies

8. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

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)
Discussion started by: rveri
3 Replies

9. Shell Programming and Scripting

[FUN] Numbers to Roman letters/num

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)
Discussion started by: sea
9 Replies
RYGEL(1)							 Rygel User Manual							  RYGEL(1)

NAME
rygel - a collection of DLNA/UPnP AV services SYNOPSIS
rygel [options] DESCRIPTION
rygel is a home media solution that allows you to easily share audio, video and pictures, and control of media player on your home network. In technical terms it is both a UPnP AV MediaServer and MediaRenderer implemented through a plug-in mechanism. Interoperability with other devices in the market is achieved by conformance to very strict requirements of DLNA and on the fly conversion of media to format that client devices are capable of handling. OPTIONS
The program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. -h, --help Show summary of options. --help-all Show all help options. --help-gst Show GStreamer related help options. --version Show version of program. -n, --network-interface=INTERFACE Set the network-interface rygel listens on. -p, --port=PORT Set the listen-port. -t, --disable-transcoding Disable any transcoding. -m, --disable-mp3-transcoder Disable transcoding to MP3. -s, --disable-mp2ts-transcoder Disable transcoding to MPEG2 in TS container. -l, --disable-lpcm-transcoder Disable transcoding to Linear PCM. -w, --disable-wmv-transcoder Disable transcoding to WMV. -a, --disable-aac-transcoder Disable transcoding to AAC. -z, --disable-avc-transcoder Disable transcoding to AVC. -U, --disallow-upload Disable uploading of media files via UPnP. -D, --disallow-deletion UPnP clients are not allowed to delete media files on the server. -g, --log-level=LEVEL Comma-separated list of DOMAIN:LEVEL pairs, allowing to set the log level individually for each domain, where DOMAIN is eiher "*", "rygel" or the name of a plugin. Allowed log levels are 1=critical, 2=error, 3=warning, 4=message/info, 5=debug. -u, --plugin-path=PATH Set the plugin search path. -d, --disable-plugin=PLUGIN_NAME Disable the plugin PLUGIN_NAME. -i, --title=PLUGIN_NAME:TITLE Set the title of plugin PLUGIN_NAME to TITLE You can use this option more than once for every plugin you want to set the name of. -o, --plugin-option=PLUGIN_NAME: OPTION:VALUE1[,VALUE2,...] Set options for a plugin. -P, --disable-upnp Disable advertisement via UPnP and set rygel into streaming-only mode. -c --config=CONFIG_FILE Use CONFIG_FILE instead of ${XDG_CONFIG_DIR}/rygel.conf. FILES
/etc/rygel.conf The system-wide configuration file to control the behaviour of rygel. See rygel.conf(5) for further details. ${XDG_CONFIG_DIR}/rygel.conf The per-user configuration file to control the behaviour of rygel. See rygel.conf(5) for further details. ${XDG_CONFIG_DIR}/Rygel/*.xml Cached UPnP device description files. ENVIONMENT
RYGEL_DISABLE_UPNP Disable advertisement via UPnP and set rygel into streaming-only mode. RYGEL_IFACE Set the network interface to bind to. RYGEL_PORT Define the network port to bind to. RYGEL_DISABLE_TRANSCODING Disable transcoding globally. RYGEL_DISABLE_MP3_TRANS Disable the MP3 transcoder. RYGEL_DISABLE_LPCM_TRANS Disable the Linear PCM transcoder. RYGEL_DISABLE_MP2TS_TRANS Disable the MPEG2 in TS transcoder. RYGEL_DISABLE_WMV_TRANS Disable transcoding to WMV format. RYGEL_DISABLE_AAC_TRANS Disable transcoding to AAC format. RYGEL_DISABLE_AVC_TRANS Disable transcoding to AVC format. RYGEL_LOG Set the log level of rygel. RYGEL_PLUGIN_PATH Set the plugin search path of rygel. RYGEL_DISABLE_UPLOAD Disable media file upload via UPnP. RYGEL_DISABLE_DELETION Disable remote file deletion via UPnP. RYGEL_PLUGIN_TIMEOUT Set the time-out for finding the plugins. Useful to increase when running inside valgrind. Also for every plugin you can set the following environment variables: RYGEL_PLUGIN_NAME_TITLE Set the title of the plugin. RYGEL_PLUGIN_NAME_ENABLED Enable or disable the plugin. BUGS
The BTS can be found at https://bugzilla.gnome.org/buglist.cgi?product=rygel. SEE ALSO
rygel.conf(5) AUTHOR
Jens Georg <mail@jensge.org> Wrote this manpage. rygel 08/07/2012 RYGEL(1)
All times are GMT -4. The time now is 01:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy