天天看点

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 备忘录