<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>Shell - Tag - Ubuk</title>
        <link>http://localhost:1313/tags/shell/</link>
        <description>Shell - Tag - Ubuk</description>
        <generator>Hugo -- gohugo.io</generator><language>zh-CN</language><managingEditor>mymail_yjj@qq.com (o( ￣⌣￣ )o)</managingEditor>
            <webMaster>mymail_yjj@qq.com (o( ￣⌣￣ )o)</webMaster><lastBuildDate>Sat, 24 May 2025 17:29:06 &#43;0800</lastBuildDate><atom:link href="http://localhost:1313/tags/shell/" rel="self" type="application/rss+xml" /><item>
    <title>Shell脚本</title>
    <link>http://localhost:1313/posts/about_linux/shell%E8%84%9A%E6%9C%AC/</link>
    <pubDate>Sat, 24 May 2025 17:29:06 &#43;0800</pubDate>
    <author>o( ￣⌣￣ )o</author>
    <guid>http://localhost:1313/posts/about_linux/shell%E8%84%9A%E6%9C%AC/</guid>
    <description><![CDATA[<h2 id="简介">简介</h2>
<p>Shell 脚本是一种解释型语言（区别于 C 语言等编译型语言），本质上是 Shell 命令的有序集合。</p>
<h3 id="基本步骤">基本步骤</h3>
<ol>
<li><strong>创建脚本文件</strong></li>
</ol>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">vi filename.sh
</span></span><span class="line"><span class="cl"><span class="c1"># 输入命令，例如</span>
</span></span><span class="line"><span class="cl">date
</span></span></code></pre></td></tr></table>
</div>
</div><ol start="2">
<li><strong>赋予执行权限</strong></li>
</ol>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">chmod <span class="m">740</span> filename.sh
</span></span><span class="line"><span class="cl"><span class="c1"># 或者</span>
</span></span><span class="line"><span class="cl">chmod u+x filename.sh
</span></span></code></pre></td></tr></table>
</div>
</div><ol start="3">
<li><strong>执行脚本</strong></li>
</ol>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">./filename.sh
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="shell-变量">Shell 变量</h2>
<blockquote>
<p>注意：等号两边不能加空格；变量名通常使用全大写。</p>]]></description>
</item>
</channel>
</rss>
