<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>dwt&#039;s life - shell</title>
<link>https://dwt.life/tag/shell/</link>
<atom:link href="https://dwt.life/feed/tag/shell/" rel="self" type="application/rss+xml" />
<language>zh-CN</language>
<description></description>
<lastBuildDate>Sat, 20 Nov 2021 20:35:20 +0800</lastBuildDate>
<pubDate>Sat, 20 Nov 2021 20:35:20 +0800</pubDate>
<item>
<title>liunx下选择文件大小为0的文件（find)</title>
<link>https://dwt.life/archives/145/</link>
<guid>https://dwt.life/archives/145/</guid>
<pubDate>Sat, 20 Nov 2021 20:35:20 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[查找当前路径下所有文件大小为0的文件，并输出这些文件的名字find . -name &quot;*&quot; -type f -size 0c &gt; out.txt#find . -nam...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p>查找当前路径下所有文件大小为0的文件，并输出这些文件的名字</p><pre><code class="lang-shell">find . -name &quot;*&quot; -type f -size 0c &gt; out.txt
#find . -name 之间有空格 </code></pre><p>修改对应的 -size 参数就可以查找指定大小的文件，如1k大小的文件（注意不要用 -size 1k，这个得到的是占用空间1k，不是文件大小1k的）</p><p><code>find . -name &quot;*&quot; -type f -size 1024c</code></p><p>删除指定的文件</p><p><code>find . -name &quot;*&quot; -type f -size 0c | xargs -n 1 rm -f</code></p><p>查询出所有的空文件夹</p><p><code>find -type d -empty</code></p><p>查找指定的文件名</p><p><code>find . -name &quot;name.txt&quot;</code></p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://dwt.life/archives/145/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/tag/shell/</wfw:commentRss>
</item>
<item>
<title>Linux下Shell的for循环语句</title>
<link>https://dwt.life/archives/98/</link>
<guid>https://dwt.life/archives/98/</guid>
<pubDate>Fri, 06 Aug 2021 11:28:00 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[第一类：数字性循环for1-1.sh#!/bin/bash    for((i=1;i&lt;=10;i++));  do   echo $(expr $i \* 3 + 1);  done  ...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<h2>第一类：数字性循环</h2><p>for1-1.sh</p><pre><code>#!/bin/bash  
  
for((i=1;i&lt;=10;i++));  
do   
echo $(expr $i \* 3 + 1);  
done  </code></pre><hr><p>for1-2.sh</p><pre><code>#!/bin/bash  
  
for i in $(seq 1 10)  
do   
echo $(expr $i \* 3 + 1);  
done   </code></pre><hr><p>for1-3.sh</p><pre><code>#!/bin/bash  
  
for i in {1..10}  
do  
echo $(expr $i \* 3 + 1);  
done  </code></pre><hr><p>for1-4.sh</p><pre><code>#!/bin/bash  
  
awk &#039;BEGIN{for(i=1; i&lt;=10; i++) print i}&#039;  </code></pre><h2>第二类：字符性循环</h2><p>for2-1.sh</p><pre><code>#!/bin/bash  
  
for i in `ls`;  
do   
echo $i is file name\! ;  
done   </code></pre><hr><p>for2-2.sh</p><pre><code>#!/bin/bash  
  
for i in $* ;  
do  
echo $i is input chart\! ;  
done  </code></pre><hr><p>for2-3.sh</p><pre><code>#!/bin/bash  
  
for i in f1 f2 f3 ;  
do  
echo $i is appoint ;  
done  </code></pre><hr><p>for2-4.sh</p><pre><code>#!/bin/bash  
  
list=&quot;rootfs usr data data2&quot;  
for i in $list;  
do  
echo $i is appoint ;  
done  </code></pre><h2>第三类：路径查找</h2><p>for3-1.sh</p><pre><code>#!/bin/bash  
  
for file in /proc/*;  
do  
echo $file is file path \! ;  
done  </code></pre><hr><p>for3-2.sh</p><pre><code>#!/bin/bash  
  
for file in $(ls *.sh)  
do  
echo $file is file path \! ;  
done  </code></pre><p>总结：</p><p>现在一般都使用for in结构，for in结构后面可以使用函数来构造范围，比如$()、``这些，里面写一些查找的语法，比如ls test*，那么遍历之后就是输出文件名了。</p><p>参考：</p><p><a href="http://blog.csdn.net/babyfish13/article/details/52981110">http://blog.csdn.net/babyfish13/article/details/52981110</a></p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://dwt.life/archives/98/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/tag/shell/</wfw:commentRss>
</item>
</channel>
</rss>