2019-04-21 11:50:48 +08:00

44 lines
2.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="sh">sh</h1>
<p>shell命令解释器</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>sh命令</strong> 是shell命令语言解释器执行命令从标准输入读取或从一个文件中读取。通过用户输入命令和内核进行沟通Bourne Again Shell 即bash是自由软件基金会GNU开发的一个Shell它是Linux系统中一个默认的Shell。Bash不但与Bourne Shell兼容还继承了C Shell、Korn Shell等优点。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">bash [options] [file]</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-c string命令从-c后的字符串读取。
-i实现脚本交互。
-n进行shell脚本的语法检查。
-x实现shell脚本逐条语句的跟踪。</code></pre>
<h3 id="实例">实例</h3>
<p>使用-x选项跟踪脚本调试shell脚本能打印出所执行的每一行命令以及当前状态</p>
<pre><code class="language-bash">[root@AY1307311912260196fcZ satools]# sh -x check_ssh_login.sh
+ DEFINE=30
+ cat /var/log/secure
+ awk &#39;/Failed/ {++ip[$(NF-3)]} END {for (i in ip) print i&quot;=&quot;ip[i]}&#39;
++ cat /root/satools/black.txt
+ for i in &#39;`cat /root/satools/black.txt`&#39;
++ echo 121.42.0.16=1427
++ awk -F= &#39;{print $1}&#39;
+ IP=121.42.0.16
++ echo 121.42.0.16=1427
++ awk -F= &#39;{print $2}&#39;
+ NUM=1427
+ &#39;[&#39; 1427 -gt 30 &#39;]&#39;
+ grep 121.42.0.16 /etc/hosts.deny
+ &#39;[&#39; 1 -gt 0 &#39;]&#39;
+ echo sshd:121.42.0.16
+ echo vsftpd:121.42.0.16
+ for i in &#39;`cat /root/satools/black.txt`&#39;
++ echo 121.42.0.72=276
++ awk -F= &#39;{print $1}&#39;
+ IP=121.42.0.72
++ awk -F= &#39;{print $2}&#39;
++ echo 121.42.0.72=276
+ NUM=276
+ &#39;[&#39; 276 -gt 30 &#39;]&#39;
+ grep 121.42.0.72 /etc/hosts.deny
+ &#39;[&#39; 1 -gt 0 &#39;]&#39;
+ echo sshd:121.42.0.72
+ echo vsftpd:121.42.0.72</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->