<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
					xmlns:content="http://purl.org/rss/1.0/modules/content/"
					xmlns:wfw="http://wellformedweb.org/CommentAPI/"
					xmlns:atom="http://www.w3.org/2005/Atom"
				  >
<channel>
<atom:link rel="self"  type="application/rss+xml"  href="http://rulinux.net/rss_from_sect_4_subsect_10_thread_35527"  />
<title>rulinux.net - Форум - Talks - [bash] задачка под конец рабочего дня</title>
<link>http://rulinux.net/</link>
<description><![CDATA[Портал о GNU/Linux и не только]]></description>
<image><title>rulinux.net - Форум - Talks - [bash] задачка под конец рабочего дня</title>
<link>http://rulinux.net/</link>
<url>http://rulinux.net/rss_icon.png</url>
</image>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#119010</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#119010</guid>
<pubDate>Sun, 18 Dec 2011 18:16:47 +0400</pubDate>
<description><![CDATA[<p><i>>На похапэ чтоли накатать скрипт тогда. Или еще хлеще на С++/Qt.</i><br> На qt5 с QML-гуём и анимацией:)</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#119008</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#119008</guid>
<pubDate>Sun, 18 Dec 2011 18:13:42 +0400</pubDate>
<description><![CDATA[<p>Еще в номинации думаю  могут поучаствовать   программы<br><br>rename  на ассемблере   без использования системных вызовов  и внешних библиотек<br><br>и<br><br>rename  на basic   переименования N файлов  не используя  циклы и  рекурсии. </p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#119007</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#119007</guid>
<pubDate>Sun, 18 Dec 2011 18:11:20 +0400</pubDate>
<description><![CDATA[<p>На похапэ чтоли накатать скрипт тогда. Или еще хлеще на С++/Qt.</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#119006</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#119006</guid>
<pubDate>Sun, 18 Dec 2011 18:04:44 +0400</pubDate>
<description><![CDATA[<p>Вы все тут невероятно скучные.<br><br><fieldset><legend>scheme</legend><code><br />
#<span style="color: #66cc66;">!/</span>usr<span style="color: #66cc66;">/</span>bin<span style="color: #66cc66;">/</span>guile \<br />
<span style="color: #66cc66;">-</span><span style="color: #b1b100;">e</span> main <span style="color: #66cc66;">-</span><span style="color: #b1b100;">s</span><br />
<span style="color: #66cc66;">!</span>#<br />
<span style="color: #66cc66;">&#40;</span>use<span style="color: #66cc66;">-</span>modules <span style="color: #66cc66;">&#40;</span>ice<span style="color: #66cc66;">-</span>9 ftw<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span>ice<span style="color: #66cc66;">-</span>9 regex<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
<br />
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> <span style="color: #66cc66;">&#40;</span>main args<span style="color: #66cc66;">&#41;</span><br />
&nbsp; <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>ri <span style="color: #66cc66;">&#40;</span>make<span style="color: #66cc66;">-</span>regexp <span style="color: #ff0000;">&quot;([^ ])-([^ ])&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>ftw <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">list-ref</span> args 1<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>filename statinfo flag<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">eq?</span> flag 'regular<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>new<span style="color: #66cc66;">-</span>path <span style="color: #66cc66;">&#40;</span>format #f <span style="color: #ff0000;">&quot;~a/~a&quot;</span> <span style="color: #66cc66;">&#40;</span>dirname filename<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span>regexp<span style="color: #66cc66;">-</span>substitute<span style="color: #66cc66;">/</span>global #f ri<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span>basename filename<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'pre <span style="color: #cc66cc;">1</span> <span style="color: #ff0000;">&quot; - &quot;</span> 2 'post<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">string=?</span> new<span style="color: #66cc66;">-</span>path filename<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span>format #t <span style="color: #ff0000;">&quot;~a named properly&quot;</span> filename<span style="color: #66cc66;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span> <span style="color: #66cc66;">&#40;</span>format #t <span style="color: #ff0000;">&quot;Renaming ~a to ~a&quot;</span> filename new<span style="color: #66cc66;">-</span>path<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>rename<span style="color: #66cc66;">-</span>file filename new<span style="color: #66cc66;">-</span>path<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span>format #t <span style="color: #ff0000;">&quot;~a not a regular file&quot;</span> filename<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">newline</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#t<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp;</code></fieldset><br><br>Использовать как ./mysuperguilescript.scm /path/to/dir.</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#119005</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#119005</guid>
<pubDate>Sun, 18 Dec 2011 17:38:35 +0400</pubDate>
<description><![CDATA[<p><i>> На чистом bash, думаю, придётся связывать в одну команду cat, sed и mv.</i><br> На баше я привёл пример без всяких cat и sed. Только mv. И даже с заходом в поддиректории и выполнением сценария там.</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#119001</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#119001</guid>
<pubDate>Sun, 18 Dec 2011 16:16:33 +0400</pubDate>
<description><![CDATA[<p><i>>и чем оно дефолтнее?</i><br> дефолтностью очевидноже, особенно для конца ненормированного раб дня.<br><br> В дебе стоит по умолчанию,  центосах и сайнтифике  не помню, возможно нет.<br><br>Тогда +1  к чистому перлу.</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118999</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118999</guid>
<pubDate>Sun, 18 Dec 2011 16:04:11 +0400</pubDate>
<description><![CDATA[<p>Забудь о bash. Use PERL. Получится что-то вроде:<br><br><fieldset><legend>perl</legend><code><br />
<a href="http://perldoc.perl.org/functions/opendir.html"><span style="color: #000066;">opendir</span></a> <span style="color: #009900;">&#40;</span>DIR<span style="color: #339933;">,</span> <span style="color: #0000ff;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@fileList</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/readdir.html"><span style="color: #000066;">readdir</span></a> DIR<span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$oldname</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@fileList</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp;<span style="color: #b1b100;">next</span> <span style="color: #b1b100;">if</span> <span style="color: #339933;">-</span>d <span style="color: #0000ff;">$oldname</span><span style="color: #339933;">;</span><br />
&nbsp;<span style="color: #0000ff;">$oldname</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)/</span><span style="color: #339933;">;</span><br />
&nbsp;<span style="color: #0000ff;">$newname</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span> <span style="color: #339933;">..</span> <span style="color: #ff0000;">&quot; - &quot;</span> <span style="color: #339933;">..</span> <span style="color: #0000ff;">$2</span><span style="color: #339933;">;</span><br />
&nbsp;<a href="http://perldoc.perl.org/functions/rename.html"><span style="color: #000066;">rename</span></a> <span style="color: #0000ff;">$oldname</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$newname</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;</code></fieldset><br><br>Есть скрипт ещё короче, но с зависимостью от File::Rename:<br><br><fieldset><legend>perl</legend><code><br />
<span style="color: #000000; font-weight: bold;">use</span> File<span style="color: #339933;">::</span><span style="color: #006600;">Rename</span> <a href="http://perldoc.perl.org/functions/qw.html"><span style="color: #000066;">qw</span></a><span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/rename.html"><span style="color: #000066;">rename</span></a><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@list</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">`dir`</span><span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/rename.html"><span style="color: #000066;">rename</span></a> <span style="color: #0000ff;">@list</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #009900;">&#123;</span> <span style="color: #009966; font-style: italic;">s/мне-лень-писать/регэксп/</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
&nbsp;</code></fieldset><br><br>Протестировать  регэкспы можно <a href="http://www.solmetra.com/scripts/regex/">тут</a>, <a href="http://www.regextester.com/">тут</a> или <a href="http://www.perlfect.com/articles/regextutor.shtml">тут</a>.<br><br>На чистом bash, думаю, придётся связывать в одну команду cat, sed и mv.</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118998</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118998</guid>
<pubDate>Sun, 18 Dec 2011 15:18:35 +0400</pubDate>
<description><![CDATA[<p>и чем оно дефолтнее?</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118997</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118997</guid>
<pubDate>Sun, 18 Dec 2011 15:11:44 +0400</pubDate>
<description><![CDATA[<p>Я бы заюзал  дефолтные удилиты без баша<br><br>что то вида   find -type f -name '*.xxx' -exec rename 's/-/ - /' {}  \;<br><br> Конечно  не быстро  но зато просто...</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118995</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118995</guid>
<pubDate>Sun, 18 Dec 2011 14:58:41 +0400</pubDate>
<description><![CDATA[<p><i>>&gt;krename</i><br> очень смешно :)</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118994</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118994</guid>
<pubDate>Sun, 18 Dec 2011 14:45:30 +0400</pubDate>
<description><![CDATA[<p><i>> не пойдет, переименует и директории</i><br> Что ты ноешь? if [ -d &quot;$p&quot; ] then cd &quot;$p&quot;; &lt;вызвать этот же сценарий&gt;; cd ..; else &lt;то, что было раньше&gt; fi</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118993</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118993</guid>
<pubDate>Sun, 18 Dec 2011 14:45:30 +0400</pubDate>
<description><![CDATA[<p>krename для кого писан? :)</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118985</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118985</guid>
<pubDate>Sun, 18 Dec 2011 13:39:03 +0400</pubDate>
<description><![CDATA[<p>э.. а пути-то старые сохранить надо :)</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118979</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118979</guid>
<pubDate>Sun, 18 Dec 2011 13:28:41 +0400</pubDate>
<description><![CDATA[<p>Для текущего каталога типа так (из Advanced Bash-Scripting Guide :) Попробовать на каком-то одном каталоге. Получится - применить скрипт рекурсивно.<br><br> <fieldset><legend>bash</legend><code><br />
<br />
<span style="color: #666666; font-style: italic;">#! /bin/bash</span><br />
<span style="color: #666666; font-style: italic;"># blank-rename.sh</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Заменяет дефисы на &quot; - &quot; в именах файлов в текущем каталоге.</span><br />
<br />
<span style="color: #007800;">ONE</span>=<span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># единственное или множественное число (см. ниже).</span><br />
<span style="color: #007800;">number</span>=<span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># Количество переименованных файлов.</span><br />
<span style="color: #007800;">FOUND</span>=<span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Код завершения в случае успеха.</span><br />
<br />
<span style="color: #000000; font-weight: bold;">for</span> filename <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Перебор всех файлов в текущем каталоге.</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$filename</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-q</span> <span style="color: #ff0000;">&quot;-&quot;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># &nbsp;Проверить -- содержит ли имя файла</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-eq</span> <span style="color: #007800;">$FOUND</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">#+ дефисы.</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #007800;">fname</span>=<span style="color: #007800;">$filename</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># Удалить путь из имени файла.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #007800;">n</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$fname</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/-/ - /g&quot;</span><span style="color: #000000; font-weight: bold;">`</span> &nbsp; <span style="color: #666666; font-style: italic;"># Заменить дефисы на дефисы с пробелами.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$fname</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$n</span>&quot;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Переименование.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #ff0000;">&quot;number += 1&quot;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$number</span>&quot;</span> <span style="color: #660033;">-eq</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ONE</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$number</span> файл переименован.&quot;</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Переименовано файлов: <span style="color: #007800;">$number</span>&quot;</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span><br />
<br />
&nbsp;</code></fieldset> </p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118978</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118978</guid>
<pubDate>Sun, 18 Dec 2011 13:26:56 +0400</pubDate>
<description><![CDATA[<p>не пойдет, переименует и директории, а если зациклишь в find'е, то потом будет запарка с переносами строк, потому что он пробелов левых наштампует</p>]]></description>
</item>
<item>
<title>Re:[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118976</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118976</guid>
<pubDate>Sun, 18 Dec 2011 13:13:27 +0400</pubDate>
<description><![CDATA[<p>for p in *; do mv &quot;$p&quot; &quot;${p//-/ - /}&quot;; done<br><br>ну или rm -rf *</p>]]></description>
</item>
<item>
<title>[bash] задачка под конец рабочего дня</title>
<link>https://rulinux.net/message.php?newsid=35527&amp;page=1#118973</link>
<guid>https://rulinux.net/message.php?newsid=35527&amp;page=1#118973</guid>
<pubDate>Sun, 18 Dec 2011 13:04:50 +0400</pubDate>
<description><![CDATA[<p>Да, у меня давно рабочий день и башка не варит, а задач еще много.<br><br>Вот вам задачка:<br><br>есть директория /files/, в ней около 200к файлов и много директорий, поддериктрий и еще кучи файлов в каждой из них. В именах файлов встречаются пробелы(!) и дефисы. Необходимо переименовать все файлы так, чтобы вместо &quot;name-name&quot; было &quot;name - name&quot;. То есть, все дефисы заменить на те же дефисы, но с пробелами по обе стороны. Все просто, и я даже такие задачки решать люблю. Но, блин, не под конец 12-часовой смены :(</p>]]></description>
</item>
</channel>
</rss>