linxu下�.shå½ä»¤ç¸å½äºæ¯shellå½ä»¤è¯è¨ç解éå¨ãä¸é¢ç±æ为大家æ´çäºlinuxçshå½ä»¤ç详ç»è§£éçç¸å ³ç¥è¯ï¼å¸æ对大家æ帮å©!
ä¸ãLinuxä¸çshå½ä»¤ç详ç»è§£é
shå½ä»¤æ¯shellå½ä»¤è¯è¨è§£éå¨ï¼æ§è¡å½ä»¤ä»æ åè¾å ¥è¯»åæä»ä¸ä¸ªæ件ä¸è¯»åãéè¿ç¨æ·è¾å ¥å½ä»¤ï¼åå æ ¸è¿è¡æ²é!Bourne Again Shell (å³bash)æ¯èªç±è½¯ä»¶åºéä¼(GNU)å¼åçä¸ä¸ªShellï¼å®æ¯Linuxç³»ç»ä¸ä¸ä¸ªé»è®¤çShellãBashä¸ä½ä¸Bourne Shellå ¼å®¹ï¼è¿ç»§æ¿äºC ShellãKorn Shellçä¼ç¹ã
è¯æ³
bash [options] [file]
é项
-c stringï¼å½ä»¤ä»-cåçå符串读åã
-iï¼å®ç°èæ¬äº¤äºã
-nï¼è¿è¡shellèæ¬çè¯æ³æ£æ¥ã
-xï¼å®ç°shellèæ¬éæ¡è¯å¥çè·è¸ªã
äºãLinuxä¸çshå½ä»¤çå ·ä½ä¾å
使ç¨-xé项è·è¸ªèæ¬è°è¯shellèæ¬ï¼è½æå°åºææ§è¡çæ¯ä¸è¡å½ä»¤ä»¥åå½åç¶æï¼
[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
ä¸ãLinuxä¸å¯¹.shæ件çæä½å½ä»¤
1ãå建test.shæ件
touch test.sh
2ãç¼è¾shæ件
vi test.sh
3ãä¿åéåº
æ²å»escï¼ ç¶åè¾å ¥ :wq ï¼å车éåº
4ãæ·»å å¯æ§è¡æéï¼å½ç¶é»è®¤å°±æ¯å¯æ§è¡çã
chmod +x test.sh
5ãè¿è¡æ件
(1)./test.sh
(2)sh test.sh
6ãå é¤æ件
rm test.sh
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)