++shell´¦ÀíÃüÁîµÄ˳Ðò
±ðÃû¡ª¹Ø¼ü´Ê(if,function,while¡)¡ªº¯Êý¡ªÄÚÖÃÃüÁ¿ÉÖ´ÐÐÎļþºÍ½Å±¾
++ÄÚÖÃÃüÁîÓ÷¨²éѯ
help command
++ÄÚÖÃÃüÁîÆôÓùرÕ
enable -n pwd #¹Ø±ÕpwdÃüÁî
enable pwd #¿ªÆôpwdÃüÁî
++¿ØÖÆͨÅä·û(Globbing)
set noglob »ò set -f #¹Ø±ÕͨÅä·û,ÔÙÊÔÊÔ¡±ls *¡±¿´¿´,ºÇ.
#»Ö¸´ set +f
++ͳ¼ÆÖظ´ÐÐ
sort file|uniq -c
++ÔÚÎļþµÄÿһÐеÄÐÐβ,×Ô¶¯Ìí¼ÓÒ»¸ö¡±;¡±·ûºÅ
sed ¡®s/$/;/¡¯ sourefile > targetname
++if then elseÑ»·ÖÐ,Èç¹ûÐèÒªthen²¿·Ö²»Ö´ÐÐÈκÎÖ¸Áî,
if [ -d $tmp ]
then
:
else
mkdir -p $tmp
fi
++$@µÈÌض¨shell±äÁ¿µÄº¬Òå
$# ´«µÝµ½½Å±¾µÄ²ÎÊý¸öÊý
$* ÒÔÒ»¸öµ¥×Ö·û´®ÏÔʾËùÓÐÏò½Å±¾´«µÝµÄ²ÎÊý¡£ÓëλÖñäÁ¿²»Í¬£¬´ËÑ¡Ïî²ÎÊý¿É³¬¹ý9¸ö
$$ ½Å±¾ÔËÐеĵ±Ç°½ø³ÌIDºÅ
$! ºǫ́ÔËÐеÄ×îºóÒ»¸ö½ø³ÌµÄ½ø³ÌIDºÅ
$@ Óë$#Ïàͬ£¬µ«ÊÇʹÓÃʱ¼ÓÒýºÅ£¬²¢ÔÚÒýºÅÖзµ»Øÿ¸ö²ÎÊý
$- ÏÔʾshellʹÓõĵ±Ç°Ñ¡ÏÓësetÃüÁÄÜÏàͬ
$? ÏÔʾ×îºóÃüÁîµÄÍ˳ö״̬¡£0±íʾûÓдíÎó£¬ÆäËûÈκÎÖµ±íÃ÷ÓдíÎó¡£
++PS1Ö§³ÖµÄ±äÁ¿ËµÃ÷
ĬÈÏ: [\u@\h \W]\$
\t µ±Ç°Ê±¼äÊÇHH:MM:SS¸ñʽ
\d ÈÕÆÚÊÇ¡±ÐÇÆÚ Ô ÈÕ¡±¸ñʽ
\n »»Ðзû
\s shellµÄÃû×Ö,$0µÄ»ùÃû
\w µ±Ç°¹¤×÷Ŀ¼
\W µ±Ç°¹¤×÷Ŀ¼µÄ»ùÃû
\u µ±Ç°Óû§Ãû
\h Ö÷»úÃû
\# ¸ÃÃüÁîµÄ±àºÅ
\! ¸ÃÃüÁîµÄÀúÊ·±àºÅ
\$ Èç¹ûUIDÊÇ0,ÔòΪ#,·ñÔòÊÇ$
#ÒÔÏÂΪbash 2.x°æ²ÅÖ§³ÖµÄ
\@ ÒÔ12Сʱam/pm¸ñʽ±íʾµ±Ç°Ê±¼ä
\H Ö÷»úÃû
\T ÒÔ12Сʱ¸ñʽ±íʾµ±Ç°Ê±¼ä
++È¡³öÁ½¸öĿ¼Öв»Í¬µÄÎļþ
cat dir1.list dir2.list |sort|uniq -u
++ ʹÓà seq À´²úÉúÑ»·²ÎÊý
for a in `seq 80` #»òÕß for a in $( seq 80 ) ,Óë ¡± for a in 1 2 3 4 5 ¡ 80 ¡°Ïàͬ (ÉÙÇÃÁ˺öà×Ö!).
for a in `seq $BEGIN $END` #´«¸ø ¡°seq¡± Á½¸ö²ÎÊý, ´ÓµÚÒ»¸ö²ÎÊý¿ªÊ¼Ôö³¤, Ò»Ö±Ôö³¤µ½µÚ¶þ¸ö²ÎÊýΪֹ.
for a in `seq $BEGIN $INTERVAL $END` #´«¸ø ¡°seq¡± Èý¸ö²ÎÊý´ÓµÚÒ»¸ö²ÎÊý¿ªÊ¼Ôö³¤,²¢ÒÔµÚ¶þ¸ö²ÎÊý×÷ΪÔöÁ¿, Ò»Ö±Ôö³¤µ½µÚÈý¸ö²ÎÊýΪֹ.
++ÊäÈëʱÆÁÄ»²»ÏÔʾ(±È½ÏÊäÈëÃÜÂë)
stty -echo #¹Ø±ÕÆÁÄ»µÄecho
stty echo #»Ö¸´ÆÁÄ»Ôecho
++È¡µÃÒ»¸öÕýÔÚÔËÐнø³ÌµÄPID
pidof servername
pgrep servername
++ÔÚµ¥ÒýºÅÖÐÒýÈë$±äÁ¿
ls -l $PATH0$i |awk ¡®{print $9}¡¯|sed ¡®s/^/\\\\192.168.1.1\\Lib\\¡¯$i¡¯\\/¡¯
++()ºÍ{}Çø±ð
(cmds) ÔÚ×ÓshellÖÐÖ´ÐÐ
{cmds}ÔÚµ±Ç°shellÖÐÖ´ÐÐ
++echo Ïà¹Ø²ÎÊý
-e ÔÊÐí½âÊÍתÒåÐòÁÐ -n ɾ³ýÊä³ö½á¹ûµÄ»»Ðзû
תÒåÐòÁÐ
\a ±¨¾¯ \b Í˸ñ \n»»ÐÐ \r»Ø³µ \tÖƱí·û
++readÏà¹Ø
read -p ¡°how old r u? ¡± age #-p¿ÉÒÔÊä³öÐÅÏ¢
read -p ¡°some words? ¡± -a words #-aÊäÈëÒ»×é×Ö½Ú,ÐèÒªecho ${words[*]}È¡³ö.
read -p ¡°Password: ¡± -s passwd #-s ÊʺÏÊäÃÜÂë,²»»ØÏÔÓÚÆÁÄ»
++È¡µÃ×òÌìµÄÈÕÆÚ
yesterday=`date -d ¡°1 day ago¡± +%Y%m%d`
++½Å±¾ÖÐʵÏÖpauseЧ¹û
read -n1 -p ¡°Press any key to continue¡¡±
++Ò»¸öÅжÏyes/noµÄ½Å±¾
#!/bin/bash echo ¡°please input ¡®yes¡¯ or ¡®no¡¯¡± read answer if [ "$answer" = "yes" ]; then echo ¡°yes¡± else echo ¡°no¡±
++°ÑÎļþÖеIJ»¹æÔòÊýÁ¿(N¸ö)µÄ¿Õ¸ñ×Ö·û»»³Éµ¥¸ö¿Õ¸ñ×Ö·û
cat file |sed ¡®s/ \{2,\}/ /g¡¯
cat file |tr -s ¡® ¡®
++ÈçºÎÔÚ±àдSHELLÏÔʾ¶à¸öÐÅÏ¢£¬ÓÃEOF
cat << EOF
+¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¨C+
| === Welcome to Tunoff services === |
+¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¨C+
EOF
++°ÑÒ»¸öÎļþÀïÃæÒ»ÁеÄ×Ö·û´®¶¼¸³Öµµ½Ò»¸öÊý×éÀïÃæ²¢µ÷ÓÃ
# cat test
test-001
test-002
test-003
test-004
# filename=(`cat test|sed -e :a -e ¡®$!N;s/\\n/ /;ta¡¯`)
# set|grep filename
filename=([0]=¡±test-001¡å [1]=¡±test-002¡å [2]=¡±test-003¡å [3]=¡±test-004¡å)
echo ${filename2[0]}
++forÑ»·ÖÐ×Ô¶¯Éú³ÉÀÛ¼ÓÊý
for ((i=0; i<100000; i++));
do
echo $i
done
++ÓÃÊý×éÐÎʽ´æ·Å10±äÁ¿Öµ£¬È»ºóÓÃforÊä³ö
#!/bin/bash name=(a b c d e f g h j i) for i in ${name[*]} do echo $i done
ÍƼöÐÅÏ¢
- linuxÃüÁîѧϰ±Ê¼Ç£¨11£©£ºnlÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨5£©£ºrmÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨4£©£ºmkdirÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨1£©£ºlsÃüÁî
- ½«CentosµÄyumÔ´¸ü»»Îª¹úÄڵİ¢ÀïÔÆÔ´
- ʹÓÃNginxÌí¼Óheader·ÀÖ¹ÍøÒ³±»frame
- linuxϼÓËÙscp´«Êä´óÎļþµÄËÙ¶È
- linuxϵͳÉ϶ÔnginxÈÕÖ¾·Ö¸î´¦Àí
- lnmp/nginxϵͳÕæÕýÓÐЧµÄͼƬ·ÀµÁÁ´ÍêÕûÉèÖÃÏê½â
- Í»ÆÆÊ®Íò²¢·¢µÄNginxµÄÅäÖü°ÓÅ»¯
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- ²éÕÒ²¢É¾³ý.svnĿ¼Îļþ
- redis ÆßÖÖÊý¾ÝÀàÐ͵ÄʹÓó¡¾°
- linux ÏÂÎļþ¸´ÖƵ½windowsÏÂÂÒÂëµÄ½â¾ö°ì·¨
- nginx³öÏÖ502 upstream sent too big he....
- linuxÏÂsudoÅäÖÃÏê½â
- linuxÃüÁîѧϰ±Ê¼Ç£¨15£©£ºtailÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨14£©£ºheadÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨13£©£ºlessÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨12£©£ºmoreÃüÁî
- ¼ÓÃÜËã·¨±È½Ï3DES AES RSA ECC MD5 SHA1µÈ
ÆÀÂÛ