shellä¸åéçèµå¼æ¹æ³ä¸è¬æ¯ variable=variable_value,ä½æ¯å¨å®é
è¿ç¨è¿ç¨ä¸ï¼variable_valueå¯ä»¥æå¤ç§æ¹æ³å
·ä½å¦ä¸ï¼
variable=`command argument` å 个å
¸åçä¾åï¼
ç¨awkæè
æ¯cut ææå®çå段ï¼ç¨ä¸å®ç
åé符åéçå段ï¼èµå¼ç»æ个åé variable=`awk '{print $n}' filename` ç¨cutä¹è½å®ç°ç±»ä¼¼çåæ³
ç¨awkçsubstrå½æ°ææå®å段çæå 个å符èµå¼ç»variableï¼çä¸è¾¹çä¾åï¼ ifconfig |grep "inet addr" |awk '{print substr($2,6)}'
ç¨forå½æ°ææå®èå´çå¼èµå¼ç»åé for i in `cat file.txt` do do sth here done ç¨ä»£ç åéå®åï¼ while read line do do sth here done < filename
代ç åéå®å:ä¸æ¬¡è¯»åä¸è¡ï¼æ件ä¸çå段å¦æç¨ç©ºæ ¼åå¼é£ä¹ç¨ä»£ç åéå®åå¤çåå个åéä¹ç¨ç©ºæ ¼åå¼