Re: bash scripts conditionals and substrings

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Craig White
Date:  
To: plug-discuss
Subject: Re: bash scripts conditionals and substrings
On Mon, 2005-02-28 at 20:30 -0700, Kevin wrote:
> On Mon, 2005-02-28 at 20:05 -0700, Craig White wrote:
> >    if ${i:6:5} = "START"
> >       then printf $i >> $outfile
> >    else
> >       printf "if (!function_exists('_prefs_hook_$i')) { \n\n" >>
> > $outfile

> >
> >    fi

>
>
> Maybe something like this?
> if `echo $i | awk '{print substr($i,6,5)}'` = "START"
>
> I have not tried it. I'm just guessing. :) But seriously, the
> substring function of awk (substr) jumped to mind. You might be able to
> leverage it. I don't have my bash book handy, but there is probably a
> more elegant way to handle this directly in bash.

----
that may be a very good conditional...

but the problem I am having is still the part...

do if `echo $i | awk '{print substr($i,6,5)}'` = "START"

which actually tries to execute the results of the substring function,
much like my previous example with the substring function I was trying
to do directly in bash.

there is sort of black art thing to shell scripting that I didn't learn
and my bash book doesn't impart upon me.

Craig

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss