Re: [gelöst]Re: /bin/sh: prüfen ob String1 "Wort" aus String2 enthält
> 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
> --<--<--
etwas schöner und effizienter:
#!/bin/bash
PKGNAMES="anton caesar heinrich nordpol ludwig emil otto"
INSTALLED_PKGS="anton berta caesar dora emil friedrich gustav heinrich"
script='PKGS="" ; for p in $PKGNAMES ; do case $p in (nonsense'
for i in $INSTALLED_PKGS ; do script=${script}\|$i ; done
script=${script}') PKGS="$PKGS $p" ;; esac ; done ; echo $PKGS'
eval ${script}
Gruß
Christian
--
Christian Knoke * * * http://cknoke.de
* * * * * * * * * Ceterum censeo Microsoft esse dividendum.
Reply to: