So close (scripting help)

Bill McGonigle bill at bfccomputing.com
Tue Nov 9 12:31:01 EST 2004


Non-trivial shell scripting confuses me... here's how you might do it 
in perl:

#!/usr/bin/perl -w
use strict;
use warnings FATAL => 'all';
while (<>) {
      #   ./Customer_Name/Feed_#/Weeklyusage.html.htm
         $_ =~ m/\/(.*)\/(.*)\/.*htm/;
         my $name = $1;
         my $feed = $2;
         print "name: $name, feed: $feed\n";
}


the (.*) are for capturing data, which get put into $1, $2, etc.   So 
you wind up with the data you want in the named variables.  while (<>) 
means 'loop through standard input'.

-Bill

----
Bill McGonigle, Owner           Work: 603.448.4440
BFC Computing, LLC              Home: 603.448.1668
bill at bfccomputing.com           Cell: 603.252.2606
http://www.bfccomputing.com/    Text: bill+text at bfccomputing.com
AIM: wpmcgonigle                Skype: bill_mcgonigle




More information about the gnhlug-discuss mailing list