[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [gelöst]Re: /bin/sh: prüfen ob String1 "Wort" aus String2 enthält



Michael Lange schrieb am 01. Jan um 23:43 Uhr:
> On Sun, 1 Jan 2017 20:33:00 +0100
> Jochen Spieker <ml@well-adjusted.de> wrote:
> 
> > Der Unterschied, den ich sehe ist, dass Du im Schleifenkopf $PKGNAMES
> > gequotet hast. Wenn mich nicht alles täuscht, dann iteriert die Schleife
> > damit nur noch genau einmal. Überprüf mal, ob das noch richtig
> > funktioniert.
> > 
> 
> Oops, hast recht... peinlich (^.^);

wieso? einmal iterieren reicht doch:

-->-->--
#!/bin/bash

INSTALLED_PKGS="anton berta caesar dora emil friedrich gustav heinrich" 
PKGNAMES="anton caesar heinrich nordpol ludwig emil otto"

script="case \$p in (nonsense"
for i in $INSTALLED_PKGS ; do script=${script}\|$i ; done
script=${script}') PKGS="$PKGS $p" ;; esac'

PKGS=""
for p in $PKGNAMES ; do
        eval ${script} 
done
echo $PKGS
--<--<--

Gruß
Christian

-- 
Christian Knoke            * * *            http://cknoke.de
* * * * * * * * *  Ceterum censeo Microsoft esse dividendum.


Reply to: