sh

shell command interpreter

Supplementary instructions

sh command is a shell command language interpreter that executes commands to read from standard input or read from a file. Communicate with the kernel through user input commands! Bourne Again Shell (bash) is a Shell developed by the Free Software Foundation (GNU). It is a default Shell in Linux systems. Bash is not only compatible with Bourne Shell, but also inherits the advantages of C Shell and Korn Shell.

grammar

bash [options] [file]

Options

-c string: The command reads from the string after -c.
-i: Implement script interaction.
-n: Perform syntax checking of shell scripts.
-x: Implements shell script statement-by-statement tracking.

Example

Use the -x option to trace the script to debug the shell script, which can print out each line of commands executed and the current status:

[root@AY1307311912260196fcZ satools]# sh -x check_ssh_login.sh
+DEFINE=30
+ cat /var/log/secure
+ awk '/Failed/ {++ip[$(NF-3)]} END {for (i in ip) print i"="ip[i]}'
++ cat /root/satools/black.txt
+ for i in ''cat /root/satools/black.txt`'
++ echo 121.42.0.16=1427
++ awk -F= '{print $1}'
+ IP=121.42.0.16
++ echo 121.42.0.16=1427
++ awk -F= '{print $2}'
+ NUM=1427
+ '[' 1427 -gt 30 ']'
+ grep 121.42.0.16 /etc/hosts.deny
+ '[' 1 -gt 0 ']'
+ echo sshd:121.42.0.16
+ echo vsftpd:121.42.0.16
+ for i in ''cat /root/satools/black.txt`'
++ echo 121.42.0.72=276
++ awk -F= '{print $1}'
+ IP=121.42.0.72
++ awk -F= '{print $2}'
++ echo 121.42.0.72=276
+ NUM=276
+ '[' 276 -gt 30 ']'
+ grep 121.42.0.72 /etc/hosts.deny
+ '[' 1 -gt 0 ']'
+ echo sshd:121.42.0.72
+ echo vsftpd:121.42.0.72