Hromadne prejmenovani souboru jeste jednou
Zdenek Pytela
letty na mrakoplas.phil.muni.cz
Úterý Červen 20 10:29:55 CEST 2000
David Sumsky píše:
> v adresari jsem mel asi 50 souboru html (stranek), jenze byly
> vsechny psany velkymi pismeny a to je problem, ponevadz html
> linky ve strankach zacinaly velkym pismenem a zbyla pismena byla
> mala.
> Takze bych potreboaval ty soubory prejmenovat tak, aby prvni
> pismeno v nazvu zustalo velke a zbyle byly male. Jak to udelat
> nejak jednoduse?
>
> A jeste neco: nekdy jsem v situaci, kdy bych potreboval z nazvu
> souboru odstrihnout priponu nebo vynechat urcitou skupinu hlasek
> (soubor.pripona --> soubor nebo soubor.pripona --> sor.pripona)
> Doted jsem to delal pres tr, jenze to je neefektivni, ponevadz mi
> to odstrani nekdy (pokud tam jsou) i jine znaky z nazvu.
> Poradte mi prosim, jak tohle udelat ...
Tohle najdete v každé dobré učebnici un*xu, v kapitole o expanzích a
substitucích v shellu. Např:
Michal Brandejs: UNIX - Linux, praktický průvodce. Grada, Praha 1996
Nebo bash (1),
${parameter#word}
${parameter##word}
The word is expanded to produce a pattern just as
in pathname expansion. If the pattern matches the
beginning of the value of parameter, then the
expansion is the value of parameter with the short-
est matching pattern deleted (the ``#'' case) or
the longest matching pattern deleted (the ``##''
case).
${parameter%word}
${parameter%%word}
The word is expanded to produce a pattern just as
in pathname expansion. If the pattern matches a
trailing portion of the value of parameter, then
the expansion is the value of parameter with the
shortest matching pattern deleted (the ``%'' case)
or the longest matching pattern deleted (the ``%%''
case).
--
--Zdenek Pytela, <letty na mrakoplas.phil.muni.cz>
Další informace o konferenci Linux