²»Á¼µÄʹÓÃģʽ»á½µµÍÄúµÄËٶȣ¬²¢ÇÒͨ³£»áµ¼ÖÂÒâÍâ´íÎó¡£Ñø³ÉÕâЩºÃÏ°¹ßÊǼÓÇ¿ÄúµÄ UNIX ÃüÁîÐм¼ÄܵĻý¼«²½Öè¡£
Unix ÏÂÒª²ÉÓõÄ20¸öºÃÏ°¹ßΪ£º
5. ʹÓÃתÒåÐòÁÐÀ´¹ÜÀí½Ï³¤µÄÊäÈë
8. Á˽âºÎʱ grep Ó¦¸ÃÖ´ÐмÆÊý£¬ºÎʱӦ¸ÃÈƹý
9. Æ¥ÅäÊä³öÖеÄijЩ×ֶΣ¬¶ø²»Ö»ÊǶÔÐнøÐÐÆ¥Åä
11. ʹÓÃÎļþÃû×Ô¶¯Íê³É¹¦ÄÜ (file name completion)
14. ʹÓà pushd ºÍ popd ¹ÜÀíĿ¼µ¼º½
1. ÔÚµ¥¸öÃüÁîÖд´½¨Ä¿Â¼Ê÷
Çåµ¥ 1 ÑÝʾÁË×î³£¼ûµÄ UNIX »µÏ°¹ßÖ®Ò»£ºÒ»´Î¶¨ÒåÒ»¸öĿ¼Ê÷¡£
Çåµ¥ 1. »µÏ°¹ß 1 µÄʾÀý£ºµ¥¶À¶¨Òåÿ¸öĿ¼Ê÷
~ $ mkdir tmp
~ $ cd tmp
~/tmp $ mkdir a
~/tmp $ cd a
~/tmp/a $ mkdir b
~/tmp/a $ cd b
~/tmp/a/b/ $ mkdir c
~/tmp/a/b/ $ cd c
~/tmp/a/b/c $
ʹÓà mkdir µÄ -p Ñ¡Ïî²¢ÔÚµ¥¸öÃüÁîÖд´½¨ËùÓи¸Ä¿Â¼¼°Æä×ÓĿ¼ҪÈÝÒ׵öࡣµ«ÊǼ´Ê¹¶ÔÓÚÖªµÀ´ËÑ¡ÏîµÄ¹ÜÀíÔ±£¬ËûÃÇÔÚÃüÁîÐÐÉÏ´´½¨×ÓĿ¼ʱҲÈÔÈ»Êø¸¿ÓÚÖð²½´´½¨Ã¿¼¶×ÓĿ¼¡£»¨Ê±¼äÓÐÒâʶµØÑø³ÉÕâ¸öºÃÏ°¹ßÊÇÖµµÃµÄ.
Çåµ¥ 2. ºÃÏ°¹ß 1 µÄʾÀý£ºÊ¹ÓÃÒ»¸öÃüÁîÀ´¶¨ÒåĿ¼Ê÷
~ $ mkdir -p tmp/a/b/c
Äú¿ÉÒÔʹÓôËÑ¡ÏîÀ´´´½¨Õû¸ö¸´ÔÓµÄĿ¼Ê÷£¨Ôڽű¾ÖÐʹÓÃÊǷdz£ÀíÏëµÄ£©£¬¶ø²»Ö»ÊÇ´´½¨¼òµ¥µÄ²ã´Î½á¹¹¡£
Çåµ¥ 3. ºÃÏ°¹ß 1 µÄÁíÒ»¸öʾÀý£ºÊ¹ÓÃÒ»¸öÃüÁîÀ´¶¨Ò帴ÔÓµÄĿ¼Ê÷
~ $ mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}
¹ýÈ¥£¬µ¥¶À¶¨ÒåĿ¼µÄΨһ½è¿ÚÊÇÄúµÄ mkdir ʵÏÖ²»Ö§³Ö´ËÑ¡Ïµ«ÊÇÔÚ´ó¶àÊýϵͳÉϲ»ÔÙÊÇÕâÑùÁË¡£IBM¡¢AIX®¡¢mkdir¡¢GNU mkdir ºÍÆäËû×ñÊص¥Ò» UNIX ¹æ·¶ (Single UNIX Specification) µÄϵͳÏÖÔÚ¶¼¾ßÓдËÑ¡Ïî¡£
¶ÔÓÚÈÔȻȱ·¦¸Ã¹¦ÄܵÄÉÙÊýϵͳ£¬Äú¿ÉÒÔʹÓà mkdirhier ½Å±¾£¨Çë²Î¼û²Î¿¼×ÊÁÏ£©£¬´Ë½Å±¾ÊÇÖ´ÐÐÏàͬ¹¦ÄÜµÄ mkdir µÄ°ü×°£º
~ $ mkdirhier project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}
2. ¸ü¸Ä·¾¶²»ÒªÒƶ¯´æµµ
ÁíÒ»¸ö²»Á¼µÄʹÓÃģʽÊǽ« .tar ´æµµÎļþÒƶ¯µ½Ä³¸öĿ¼£¬ÒòΪ¸ÃĿ¼ǡºÃÊÇÄúÏ£ÍûÔÚÆäÖÐÌáÈ¡ .tar ÎļþµÄĿ¼¡£ÆäʵÄú¸ù±¾²»ÐèÒªÕâÑù×ö¡£Äú¿ÉÒÔËæÐÄËùÓûµØ½«ÈκΠ.tar ´æµµÎļþ½âѹËõµ½ÈκÎĿ¼¡ª¡ªÕâ¾ÍÊÇ -C Ñ¡ÏîµÄÓÃ;¡£ÔÚ½âѹËõij¸ö´æµµÎļþʱ£¬Ê¹Óà -C Ñ¡ÏîÀ´Ö¸¶¨ÒªÔÚÆäÖнâѹËõ¸ÃÎļþµÄĿ¼£º
Çåµ¥ 4. ºÃÏ°¹ß 2 µÄʾÀý£ºÊ¹ÓÃÑ¡Ïî -C À´½âѹËõ .tar ´æµµÎļþ
~ $ tar xvf -C tmp/a/b/c newarc.tar.gz
Ïà¶ÔÓÚ½«´æµµÎļþÒƶ¯µ½ÄúÏ£ÍûÔÚÆäÖнâѹËõËüµÄλÖã¬Çл»µ½¸ÃĿ¼£¬È»ºó²Å½âѹËõËü£¬Ñø³ÉʹÓà -C µÄÏ°¹ßÔò¸ü¼Ó¿ÉÈ¡¡ª¡ªµ±´æµµÎļþλÓÚÆäËûij¸öλÖÃʱÓÈÆäÈç´Ë¡£
3. ½«ÃüÁîÓë¿ØÖƲÙ×÷·û×éºÏʹÓÃ
Äú¿ÉÄÜÒѾ֪µÀ£¬ÔÚ´ó¶àÊý Shell ÖУ¬Äú¿ÉÒÔÔÚµ¥¸öÃüÁîÐÐÉÏͨ¹ýÔÚÃüÁîÖ®¼ä·ÅÖÃÒ»¸ö·ÖºÅ (;) À´×éºÏÃüÁî¡£¸Ã·ÖºÅÊÇ Shell ¿ØÖƲÙ×÷·û£¬ËäÈ»Ëü¶ÔÓÚÔÚµ¥¸öÃüÁîÐÐÉϽ«ÀëÉ¢µÄÃüÁî´®ÁªÆðÀ´ºÜÓÐÓ㬵«Ëü²¢²»ÊÊÓÃÓÚËùÓÐÇé¿ö¡£ÀýÈ磬¼ÙÉèÄúʹÓ÷ֺÅÀ´×éºÏÁ½¸öÃüÁÆäÖеڶþ¸öÃüÁîµÄÕýÈ· Ö´ÐÐÍêÈ«ÒÀÀµÓÚµÚÒ»¸öÃüÁîµÄ³É¹¦Íê³É¡£Èç¹ûµÚÒ»¸öÃüÁîδ°´ÄúÔ¤ÆÚµÄÄÇÑùÍ˳ö£¬µÚ¶þ¸öÃüÁîÈÔÈ»»áÔËÐСª¡ª½á¹û»áµ¼ÖÂʧ°Ü¡£Ïà·´£¬Ó¦¸ÃʹÓøüÊʵ±µÄ¿ØÖƲÙ×÷·û £¨±¾ÎĽ«ÃèÊöÆäÖеIJ¿·Ö²Ù×÷·û£©¡£Ö»ÒªÄúµÄ Shell Ö§³ÖËüÃÇ£¬¾ÍÖµµÃÑø³ÉʹÓÃËüÃǵÄÏ°¹ß¡£
3.1 ½öµ±ÁíÒ»¸öÃüÁî·µ»ØÁãÍ˳ö״̬ʱ²ÅÔËÐÐij¸öÃüÁî
ʹÓà && ¿ØÖƲÙ×÷·ûÀ´×éºÏÁ½¸öÃüÁÒÔ±ã½öµ± µÚÒ»¸öÃüÁî·µ»ØÁãÍ˳ö״̬ʱ²ÅÔËÐеڶþ¸öÃüÁî¡£»»¾ä»°Ëµ£¬Èç¹ûµÚÒ»¸öÃüÁîÔËÐгɹ¦£¬ÔòµÚ¶þ¸öÃüÁÔËÐС£Èç¹ûµÚÒ»¸öÃüÁîʧ°Ü£¬ÔòµÚ¶þ¸öÃüÁî¸ù±¾¾Í²»ÔËÐС£ÀýÈ磺
Çåµ¥ 5. ºÃÏ°¹ß 3 µÄʾÀý£º½«ÃüÁîÓë¿ØÖƲÙ×÷·û×éºÏʹÓÃ
~ $ cd tmp/a/b/c && tar xvf ~/archive.tar
ÔÚ´ËÀýÖУ¬´æµµµÄÄÚÈݽ«ÌáÈ¡µ½ ~/tmp/a/b/c Ŀ¼ÖУ¬³ý·Ç¸ÃĿ¼²»´æÔÚ¡£Èç¹û¸ÃĿ¼²»´æÔÚ£¬Ôò tar ÃüÁî²»»áÔËÐУ¬Òò´Ë²»»áÌáÈ¡ÈκÎÄÚÈÝ¡£
3.2 ½öµ±ÁíÒ»¸öÃüÁî·µ»Ø·ÇÁãÍ˳ö״̬ʱ²ÅÔËÐÐij¸öÃüÁî
ÀàËƵأ¬|| ¿ØÖƲÙ×÷·û·Ö¸ôÁ½¸öÃüÁ²¢ÇÒ½öµ±µÚÒ»¸öÃüÁî·µ»Ø·ÇÁãÍ˳ö״̬ʱ²ÅÔËÐеڶþ¸öÃüÁî¡£»»¾ä»°Ëµ£¬Èç¹ûµÚÒ»¸öÃüÁî³É¹¦£¬ÔòµÚ¶þ¸öÃüÁî²»»áÔËÐС£Èç¹ûµÚÒ»¸öÃüÁî ʧ°Ü£¬ÔòµÚ¶þ¸öÃüÁî²Å»á ÔËÐС£ÔÚ²âÊÔij¸ö¸ø¶¨Ä¿Â¼ÊÇ·ñ´æÔÚʱ£¬Í¨³£Ê¹Óô˲Ù×÷·û£¬Èç¹û¸ÃĿ¼²»´æÔÚ£¬Ôò´´½¨Ëü£º
Çåµ¥ 6. ºÃÏ°¹ß 3 µÄÁíÒ»¸öʾÀý£º½«ÃüÁîÓë¿ØÖƲÙ×÷·û×éºÏʹÓÃ
~ $ cd tmp/a/b/c || mkdir -p tmp/a/b/c
Äú»¹¿ÉÒÔ×éºÏʹÓñ¾²¿·ÖÖÐÃèÊöµÄ¿ØÖƲÙ×÷·û¡£Ã¿¸ö²Ù×÷·û¶¼Ó°Ïì×îºóµÄÃüÁîÔËÐУº
Çåµ¥ 7. ºÃÏ°¹ß 3 µÄ×éºÏʾÀý£º½«ÃüÁîÓë¿ØÖƲÙ×÷·û×éºÏʹÓÃ
~ $ cd tmp/a/b/c || mkdir -p tmp/a/b/c && tar xvf -C tmp/a/b/c ~/archive.tar
4. ½÷É÷ÒýÓñäÁ¿
ʼÖÕÒª½÷É÷ʹÓà Shell À©Õ¹ºÍ±äÁ¿Ãû³Æ¡£Ò»°ã×îºÃ½«±äÁ¿µ÷ÓðüÀ¨ÔÚË«ÒýºÅÖУ¬³ý·ÇÄúÓв»ÕâÑù×öµÄ×ã¹»ÀíÓÉ¡£ÀàËƵأ¬Èç¹ûÄúÖ±½ÓÔÚ×ÖĸÊý×ÖÎı¾ºóÃæʹÓñäÁ¿Ãû³Æ£¬Ôò»¹ÒªÈ·±£½«¸Ã±ä Á¿Ãû³Æ°üÀ¨ÔÚ·½À¨ºÅ ([]) ÖУ¬ÒÔʹÆäÓëÖÜΧµÄÎı¾Çø·Ö¿ªÀ´¡£·ñÔò£¬Shell ½«°ÑβËæÎı¾½âÊÍΪ±äÁ¿Ãû³ÆµÄÒ»²¿·Ö¡ª¡ª²¢ÇҺܿÉÄÜ·µ»ØÒ»¸ö¿ÕÖµ¡£Çåµ¥ 8 ÌṩÁ˱äÁ¿µÄ¸÷ÖÖÒýÓúͷÇÒýÓü°ÆäÓ°ÏìµÄʾÀý¡£
Çåµ¥ 8. ºÃÏ°¹ß 4 µÄʾÀý£ºÒýÓ㨺ͷÇÒýÓ㩱äÁ¿
~ $ ls tmp/
a b
~ $ VAR="tmp/*"
~ $ echo $VAR
tmp/a tmp/b
~ $ echo "$VAR"
tmp/*
~ $ echo $VARa
~ $ echo "$VARa"
~ $ echo "${VAR}a"
tmp/*a
~ $ echo ${VAR}a
tmp/a
~ $
ÍƼöÐÅÏ¢
- 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µÈ
ÆÀÂÛ