̽Ë÷LinuxϵͳÖв»³£¼ûµÄÌØÊâ×Ö·û¼°ÆäÓ¦ÓÃ
ÎÊÌ⣺̽Ë÷LinuxϵͳÖв»³£¼ûµÄÌØÊâ×Ö·û¼°ÆäÓ¦ÓÃ
ÔÚLinuxϵͳÖУ¬ÌØÊâ×Ö·ûÊÇÒ»ÖÖºÜÊÇÖ÷ÒªµÄ¿´·¨£¬ËüÃÇ¿ÉÒÔÓÃÀ´¾ÙÐÐÖݪֲÙ×÷ºÍ´¦Àí¡£³ýÁ˳£¼ûµÄһЩÌØÊâ×Ö·û£¬ÈçͨÅä·ûºÍÖض¨Ïò·ûºÅÍ⣬»¹±£´æһЩ²»Ì«³£¼ûµ«¹¦Ð§Ç¿Ê¢µÄÌØÊâ×Ö·û¡£±¾ÎĽ«ÉîÈë̽Ë÷һЩ²»³£¼ûµÄÌØÊâ×Ö·û£¬²¢Í¨¹ýÏêϸµÄ´úÂëʾÀýÀ´Õ¹Ê¾ËüÃǵÄÓ¦Óá£
Ò»¡¢»¨À¨ºÅ {}
»¨À¨ºÅ {} ÊÇÒ»ÖÖºÜÓÐÓõÄÌØÊâ×Ö·û£¬¿ÉÒÔÓÃÀ´ÌìÉú¶à¸ö×Ö·ûÐòÁлòÎļþÐòÁС£ÀýÈ磬ÎÒÃÇ¿ÉÒÔͨ¹ý»¨À¨ºÅ¿ìËÙÌìÉúһϵÁÐÊý×Ö£º
echo {1..5}
µÇ¼ºó¸´ÖÆ
ÉÏÊöÏÂÁÊä³ö£º1 2 3 4 5
³ýÁËÌìÉúÊý×ÖÐòÁУ¬»¨À¨ºÅ»¹¿ÉÒÔÓÃÀ´ÌìÉúÎļþÐòÁС£ºÃ±È£¬ÔÚÄ¿½ñĿ¼ÏÂÓÐÈý¸öÎļþ file1.txt¡¢file2.txt¡¢file3.txt£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÈçÏÂÏÂÁî²Ù×÷ÕâЩÎļþ£º
mv file{1..3}.txt test/
µÇ¼ºó¸´ÖÆ
ÉÏÊöÏÂÁ°Ñ file1.txt¡¢file2.txt¡¢file3.txt Òƶ¯µ½ test Ŀ¼Ï¡£
¶þ¡¢·´ÒýºÅ
·´ÒýºÅ ÊÇÁíÒ»ÖÖÌØÊâ×Ö·û£¬Ëü¿ÉÒÔ½«ÆäÖеÄÏÂÁîÖ´Ðв¢½«Ð§¹û·µ»Ø¡£ÕâÔÚһЩÐèÒª½«ÏÂÁîÊä³ö×÷Ϊ²ÎÊýת´ï¸øÆäËûÏÂÁîʱºÜÊÇÓÐÓá£ÀýÈ磺
echo "Current directory is: `pwd`"
µÇ¼ºó¸´ÖÆ
ÉÏÊöÏÂÁÊä³öÄ¿½ñĿ¼µÄ¾ø¶Ô·¾¶¡£
Èý¡¢·½À¨ºÅ []
·½À¨ºÅ [] ͨ³£ÓÃÓÚ²âÊÔÌõ¼þ£¬ºÃ±ÈÔÚÌõ¼þÅжÏÓï¾äÖÐʹÓá£Ëü»¹¿ÉÒÔÓÃÀ´ÌìÉú×Ö·ûÐòÁС£ÀýÈ磺
echo {a..e}
µÇ¼ºó¸´ÖÆ
ÉÏÊöÏÂÁÊä³ö×ÖĸÐòÁУºa b c d e
·½À¨ºÅÒ²¿ÉÒÔÓÃÀ´ÔÚÏÂÁîÖоÙÐÐÌõ¼þÅжϣ¬ºÃ±ÈÅжÏij¸öÎļþÊÇ·ñ±£´æ£º
if [ -e filename ]; then echo "File exists" else echo "File does not exist" fi
µÇ¼ºó¸´ÖÆ
ËÄ¡¢ÃÀÔª·ûºÅ $
ÃÀÔª·ûºÅ $ ÊÇÓÃÀ´ÒýÓñäÁ¿µÄÌØÊâ×Ö·û¡£ÔÚLinuxϵͳÖУ¬ÎÒÃǾ³£ÐèҪʹÓñäÁ¿À´ÉúÑÄһЩÔÝʱÊý¾Ý»òЧ¹û£¬¶øͨ¹ýÃÀÔª·ûºÅ¿ÉÒÔÀû±ãµØÒýÓÃÕâЩ±äÁ¿¡£ÀýÈ磺
name="Alice" echo "Hello, $name"
µÇ¼ºó¸´ÖÆ
ÉÏÊöÏÂÁÊä³ö£ºHello, Alice
ÃÀÔª·ûºÅ»¹¿ÉÒÔÓÃÀ´Ö´ÐÐÏÂÁîÌæ»»£¬ºÃ±È£º
echo "Current date is: $(date)"
µÇ¼ºó¸´ÖÆ
ÉÏÊöÏÂÁÊä³öÄ¿½ñµÄÈÕÆÚºÍʱ¼ä¡£
Îå¡¢º£À˺Š~
º£À˺Š~ ͨ³£ÓÃÀ´ÌåÏÖÓû§µÄ¼ÒĿ¼¡£ÀýÈ磬ÎÒÃÇ¿ÉÒÔͨ¹ýº£À˺ÅÀ´ÌåÏÖÄ¿½ñÓû§µÄ¼ÒĿ¼£º
echo ~
µÇ¼ºó¸´ÖÆ
ÉÏÊöÏÂÁÊä³öÄ¿½ñÓû§µÄ¼ÒĿ¼·¾¶¡£
ÒÔÉÏÊÇһЩLinuxϵͳÖв»Ì«³£¼ûµ«¹¦Ð§Ç¿Ê¢µÄÌØÊâ×Ö·û¼°ÆäÓ¦ÓÃʾÀý¡£Í¨¹ýÉîÈëÏàʶºÍÊìÁ·Ó¦ÓÃÕâЩÌØÊâ×Ö·û£¬ÎÒÃÇ¿ÉÒÔ¸ü¸ßЧµØ¾ÙÐÐLinuxϵͳµÄ²Ù×÷ºÍ´¦Àí¡£Ï£Íû±¾ÎĶÔÄúÓÐËù×ÊÖú£¬½Ó´ý¼ÌÐø̽Ë÷ºÍѧϰLinuxϵͳµÄ¸ü¶àÌØÕ÷ºÍ¼¼ÇÉ¡£
ÒÔÉϾÍÊÇ̽Ë÷LinuxϵͳÖв»³£¼ûµÄÌØÊâ×Ö·û¼°ÆäÓ¦ÓõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡