On Mon, 2005-02-28 at 20:05 -0700, Craig White wrote:
> # head -n 4 /tmp/outfile.txt
> **** START OF SECTION - horde - ****
> default_identity
> identities
> identityselect
>
> #### gives you the idea of what I'm working on...
>
> What I am trying to do is see if line has "***** START ...
> and if so, write it to the outfile
> otherwise, write the other (else)
>
> The else works fine but the IF evaluates as a local file and not the
> value the 5 characters after the 6 offset and tries to execute it -
> which of course generates a whole pile of standard error junk.
---
everything but the lines that contain the **** which the conditional
gags on no matter whether I use Kevin's awk or the bash assignment, the
same thing happens...
error message...
./pref_prefs_hooks.create: line 10: [: =: unary operator expected
#!/bin/sh
infile="/tmp/outfile.txt"
outfile="/tmp/default_user.php"
> $outfile
for i in `cat $infile`;
do \
if [ `echo $i | awk '{print substr($i,5,5)}'` = "START" ]
then echo "yes"
else
echo "no"
fi
done
this line below (in place of line 10) will have the same error...
# if [ "START" == ${i:5:5} ]
but the awk command is infinitely slower to execute ;-)
I know that it is trying to execute the '*' instead of evaluate the
string $i
I don't get it...
Craig
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss