ºìÁªLinuxÃÅ»§
Linux°ïÖú

Linux Commands ÎÂÏ°ÈÕÖ¾

·¢²¼Ê±¼ä:2008-08-26 00:53:21À´Ô´:ºìÁª×÷Õß:yanliae
shellÖеÄÎļþÃûÖû»ÓëRegexpÓÐËù²»Í¬£¬ÓÐÒÔÏÂËÄÖÖ£º
1¡¢* Æ¥ÅäÈκÎ×Ö·û´®
2¡¢? Æ¥ÅäÈκε¥¸ö×Ö·û
3¡¢[¡­] Æ¥Åä[]ÖÐËù°üº¬µÄÈκÎ×Ö·û
4¡¢[!¡­] Æ¥Åä·Ç¸Ð̾ºÅÖ®ºóµÄ×Ö·û

ÕýÔò±í´ïʽ¹Ø¼ü×Ö·û£º[^*?+.$]¡¢[\{]¡¢[\}]

echo:
1¡¢-n Êä³öºó²»»»ÐÐ
2¡¢-e ʹתÒå×Ö·ûÉúЧ£¨Ä¬ÈÏÊDz»»á×Ô¶¯×ªÒåµÄ£©

read:
1¡¢Ò»´Î¶ÁÈëÒ»¸ö±äÁ¿Ê±£¬ÒÔÐÐΪ·Ö¸ô·û
2¡¢Ò»´Î¶ÁÈë¶à¸ö±äÁ¿Ê±£¬ÒÔ¿Õ¸ñΪ·Ö¸ô·û

cat:
-n -b ÏÔʾÐкÅ

Öض¨Ïò²Ù×÷£º
1¡¢2>/dev/null ¶ªÆústderr
2¡¢2>&1 stderrÖض¨Ïòµ½stdout
3¡¢command< myfile <
shellÃüÁîÁ¬½Ó£º
command1 || command2 1ʧ°Ü£¬ÔòÖ´ÐÐ2
command1 && command2 1³É¹¦£¬ÔòÖ´ÐÐ2
command1 ; command2 ; ... ˳ÐòÖ´ÐÐ

grep:
grep [options] PATTERN [files...]
·ç¸ñ£º×Ö·û´®ÓÃË«ÒýºÅ£¨"mystring"£©£¬µ÷ÓñäÁ¿Ê±Ò²ÓÃË«ÒýºÅ¡¢±äÁ¿Óá°{}¡±À¨ÆðÀ´£¨"${MYVAR}"£©£¬µ÷ÓÃģʽƥÅäʱÓõ¥ÒýºÅ£¨'\w'£©¡£
Ñ¡Ï
1¡¢-c Ö»Êä³öÆ¥ÅäÐÐÊý
2¡¢-i ²»Çø·Ö´óСд
3¡¢-n ÏÔʾƥÅäµÄÐкÅ
4¡¢-v ÏÔʾ²»Æ¥ÅäµÄËùÓÐÐÐ
5¡¢-E À©Õ¹Ä£Ê½£¬À©Õ¹ÕýÔò±í´ïʽ£¨$grep -E 'add|sub' filename£©
²éѯ¶à¸öÎļþ£º$grep "main" *.c

awk:
1¡¢FS ĬÈÏΪ¿Õ¸ô·û => OFS => NF
2¡¢RS ĬÈÏΪ»»Ðзû => ORS => NR
3¡¢¸÷¸öÓòµÄֵΪ$1 - $NF£¬$0Ϊ¼Ç¼µÄÖµ
4¡¢±È½Ï[~]¡¢[!~]Æ¥Å䲻ƥÅä
5¡¢ÄÚÖÃ×Ö·û´®º¯Êý£º
gsub(r,s)
gsub(r,s,t) Õû¸ötÖÐÓÃsÌæ´úr
index(s,t) tÖÐÕÒs
length(s)
match(s,r)
split(s,a,fs)
sprint(fmt,exp)
sub(r,s)
substr(s,p)
substr(s,p,n) ·µ»ØsÖдÓp¿ªÊ¼³¤¶ÈΪnµÄºó׺²¿·Ö

sed:
1¡¢Ä£Ê½£º[1,9]¡¢[/START/,/END/]
2¡¢¶¯×÷£º[= p s d rw gh]
3¡¢Ð޸ģº\i \a \c

commands:
whois whereis
whatis apropos
iconv ±àÂëת»»
head tail more less
find sort tr
stty ÉèÖÃÖÕ¶ËÊôÐÔ
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ