[Thread Prev][Thread Next][Index]

Re: [ferret_users] string substitution in array



Hi,

On Wed, Sep 23, 2015 at 5:29 PM, Marco van Hulten
<marco.van-hulten@xxxxxxxxxxxx> wrote:
> Le 2015-09-22 Andrew a écrit:
>> Ferret isn't really the best tool for serious string-array processing.
[. . .]
> This works fine.  So one must choose here between playing with indices
> if staying within Ferret, or using shell tools including doing some
> disk I/O.

Another approach is to manipulate the strings and invoke Ferret all
from within a scripting language (sh, bash, ruby, python, perl, etc.),
passing the strings as arguments to Ferret or storing them in a file
for Ferret to read.

This is a different example, but to illustrate the idea:

names="a_old bb_old ccc_old"
for n in $names; do
   nn=$(echo "$n" | sed 's/_old/_new/g')
   ferret -script myscript.jnl  "$n" "$nn"
done

in the sh/bash language.

You can even generate a Ferret script by such a language, embedding
the manipulated strings in the result.  This is perhaps overkill for
the problem at hand but can be useful for more complicated problems.

Regards,

Ryo



[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement