sh
aalbertini
这个作者很懒,什么都没留下…
展开
-
sh string
得到长度[Copy to clipboard] [ - ]CODE:%x="abcd"#方法一%expr length $x4# 方法二%echo ${#x}4# 方法三%expr "$x" : ".*"4# expr 的帮助# STRING : REGEXP anchored pattern match of REGEXP in STRING查找子串原创 2009-10-13 18:39:00 · 442 阅读 · 0 评论 -
调用bash shell脚本的方式
项目中经常要求一些参数可配置的; 因此会定义一个conf.sh脚本, 然后在每个需要的脚本中调用 source ./conf.sh 或者 . /conf.sh的方式。 但是如果脚本逻辑比较复杂, 可能会导致在多个父子调用的脚本中多次调用conf.sh脚本。 这样虽然没什么危害(也许有, 但暂时没发现), 但显得冗余不够美观。 可以使用export改变这种状况, 在c原创 2010-05-10 19:30:00 · 1126 阅读 · 0 评论 -
使用flex 做关键词、正则表达式过滤
编写 .l文件%{c 头文件 和变量定义%}%%{pattern} {c action code;}%%c function definitioncompile && linkflex -o my.c my.lgcc -o my my.c -lfl当无main函数时, 需要 -lfl && %option noreject noyywrap中文支持:.l 文件与需要检测的数据文件是同一编码, 否则识别不出来vim securecrt centos 编辑显示中文:centos 编辑i18n文件, 设置ut原创 2010-09-06 17:40:00 · 1284 阅读 · 1 评论 -
expect 脚本 例子
<br />#!/usr/bin/expect -f<br />set arg0 [ lindex $argv 0 ]<br />set arg1 [ lindex $argv 1 ]<br />set remoteip "172.31.13.101"<br /><br />send_user "good/n"<br />spawn /usr/bin/scp emptydoc $remoteip:/home/xiawenbing/<br />expect "yes/no)?" {send "yes/r"}原创 2010-11-24 15:23:00 · 791 阅读 · 0 评论