Simple reordering of command line arguments. 
Author Message
 Simple reordering of command line arguments.

Today I found myself reading through UnixWorld's online archives.
Which use a naming scheme like the following.

apr90.Z dec90.Z feb90.Z jan90.Z jul90.Z jun90.Z mar90.Z may90.Z nov90.Z

Now the shell doesn't return these in date order so reading this by

zcat *.Z | less

won't view them in date sequence.

So I quickly knocked up a simple perl script.  This is only my second
script in as many days. A seasoned Perl expert is welcome to suggest
any modifications so long as they keep me informed.

Anyway, I'm very new to perl so I don't know if this is the best way
to go about doing something like this.

#! /usr/local/bin/perl

# Usage: dateorder pattern

#  given a directory listing like the following
#apr90.Z dec90.Z feb90.Z jan90.Z jul90.Z jun90.Z mar90.Z may90.Z

unless ($#ARGV > -1) {
        print "Usage: order pattern\n";
        exit 1;


sub bymonth {
        %monthorder = ( "jan", 1, "feb", 2, "mar", 3, "apr", 4, "may", 5, "jun", 6, "jul", 7, "aug", 8, "sep", 9, "oct", 10, "nov", 11, "dec", 12 );


        $amon = $a; $bmon = $b;
        $amon =~ s/[0-9][0-9].Z//; $bmon =~ s/[0-9][0-9].Z//;

        $monthorder{&tolower($amon)} <=> $monthorder{&tolower($bmon)}


sub tolower {

        $string =~ tr/[A-Z]/[a-z]/;



now I can just

zcat `dateorder *.Z` | less


ZSH specific question...

Could zsh have helped out here any way? What do you think of the idea
of being able to specify your own comparators for evaluation?

                "Kill files are for pacifists"

                (ASCII for text only messages)

Tue, 01 Oct 1996 22:15:43 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Help! with command line arguments

2. running perl at command line with arguments: script.cgi?text=text

3. Command line arguments.

4. Command line arguments?

5. Passing form values back to a script as command line arguments

6. How to set varible from command line argument??

7. patch1 for wafeperl 0.2 to allow xt command line argument processing

8. Modification of command line arguments

9. Where are command line arguments described?

10. passing arguments on the command line to the script

11. Variable to get arguments from command line

12. Command line arguments


Powered by phpBB® Forum Software