<?xml version="1.0" encoding="utf-8"?> 
<rss version="2.0"
  xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
  xmlns:atom="http://www.w3.org/2005/Atom">

<channel>

<title>M9K blog: заметки с тегом find</title>
<link>https://blog.m9k.space/tags/find/</link>
<description>Заметки обо всём: devops, lifestyle, культура.</description>
<author>M</author>
<language>ru</language>
<generator>E2 (v3877; Aegea)</generator>

<itunes:owner>
<itunes:name>M</itunes:name>
<itunes:email></itunes:email>
</itunes:owner>
<itunes:subtitle>Заметки обо всём: devops, lifestyle, культура.</itunes:subtitle>
<itunes:image href="" />
<itunes:explicit></itunes:explicit>

<item>
<title>Удаление файлов в директории по префиксам в цикле</title>
<guid isPermaLink="false">58</guid>
<link>https://blog.m9k.space/all/udalenie-faylov-v-direktorii-po-prefiksam-v-cikle/</link>
<pubDate>Tue, 27 Oct 2020 15:11:27 +0000</pubDate>
<author>M</author>
<comments>https://blog.m9k.space/all/udalenie-faylov-v-direktorii-po-prefiksam-v-cikle/</comments>
<description>
&lt;p&gt;Задача: удалить файлы в директории, содержащие определённый префикс, кроме последних N новых.&lt;/p&gt;
&lt;pre class="e2-text-code"&gt;&lt;code class=""&gt;#!/bin/bash
name=(prefix1_*.type prefix2_*.type prefix3_*.type)
path=&amp;quot;/home/test&amp;quot;
for value in &amp;quot;${name[@]}&amp;quot; 
do 
find &amp;quot;$path&amp;quot; -maxdepth 1 -type f -name &amp;quot;$value&amp;quot; | sort -rn | tail -n +6 | xargs rm -rf;
done&lt;/code&gt;&lt;/pre&gt;</description>
</item>


</channel>
</rss>