Re: bash scripts conditionals and substrings

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Kevin
Date:  
To: PLUG-DISCUSS
Subject: Re: bash scripts conditionals and substrings
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.

...Kevin






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