So close (scripting help)

Steven W. Orr steveo at syslang.net
Tue Nov 9 14:53:01 EST 2004


On Tuesday, Nov 9th 2004 at 12:10 -0500, quoth Travis Roy:

=>Okay, with some big help from Chris I got so close.. but I still need one more
=>thing from my script and my extreamly bad regex skills are killing me.
=>
=>This is the output being fed in:
=>
=>./Customer_Name/Feed_#/Weeklyusage.html.htm
=>
=>I need to strip out two things. I need the Customer_Name and Feed_#
=>
=>I can do it with this command from the command line, but it gives me nothing
=>within the script.
=>
=>Here is my entire script so far
=>
=>#!/bin/bash
=>
=>for i in `find . | egrep "\/(Daily|Monthly|Weekly)usage.html.htm"`; do
=>echo "<a href=\"$i\">";
=>
=>## Below is the command that works from the command line
=>## but not from within this script. This gives me .Customer_Name
=>echo $i | awk -F/ '{ print $1 }';
=>
=>echo "</a>";
=>
=>done

#! /bin/bash
while read line
do
    c1=${line#./*}
    cn=${c1%%/*}
    f1=${c1#*/}
    fn=${f1%%/*}
done

I don't know if this is what you're looking for. Let me know.

You should never use `find` in a script because the commandline can blow 
up on you.

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



More information about the gnhlug-discuss mailing list