Jednoduchy skriptik II

Michal Weinfurtner weinfurt na securities.cz
Čtvrtek Duben 27 11:51:51 CEST 2000


Michal Krause wrote:

> On 27/04/2000, Miroslav BENES wrote:
>
> > while [ $# -gt 0 ] ; do  # existuje nejaky argument ke zpracovani ?
> >   if [ -f $1 ] ; then  # je argument existujici soubor ?
> >      ..
> >      prikazy      # ano proved prislusne akce
> >      ..
> >   fi
> >   shift                      # posun se na dalsi argument
> > done
>
> Chtel jsem jenom podotknout, ze o zdibec jednodussi je kontrukce
>
> for soubor; do
>     if [ -f $soubor ]; then
>         ...
>     fi
> done

V jakem shelu ? V bash je syntaxe trochu jina

        for name [ in word; ] do list ; done
              The list of words following in is expanded, generating a list of
items.  The variable name is set to
              each element of this list in turn, and list is executed each
time.  If the in word is  omitted,  the
              for command executes list once for each positional parameter
that is set (see PARAMETERS
              below).

Ale to neresi pripad zadani vice souboru jako argumentu z prikazove radky ?


Michal




Další informace o konferenci Linux