天天看點

shell 備忘錄

shell 備忘錄

一:

加入文本裡面有\字元,read LINE的時候,不能不正常顯示。

[root@linux-test1 test]# while read LINE; do echo $LINE; done < test.txt

#t#t#t#

[root@linux-test1 test]# while read -r LINE; do echo $LINE; done < test.txt

#\t#\t#\t#

read -r 就可以了。

假設a=abcdef

${#a}    變量a 的長度

# echo ${#a}

6

${a:n}   去掉前n個字元

# echo ${a:2}

cdef

${a:n:m}    提取a變量第n個字元右邊m個字元

# echo ${a:1:2}

bc

更多見:

http://bbs.chinaunix.net/viewthread.php?tid=218853&extra=&page=7#pid1617953

ctrl+H 輸入方法 先按ctrl+v組合鍵,再按ctrl+h組合鍵

上一篇: 通用視圖
下一篇: STL 備忘錄