`

Linux shell的问题

阅读更多

1 grep的几个参数

-a 在二进制中以文本方式Search
-c 计算次数
-v 输出不匹配的行
-n 输出行号

 

2 javascript用正则表达式来写trim函数

str.replace(/(^/s)|(/s$)/g,"")


3 var re =
* 重复0到多个前一个字符
+重复1到多个前一个字符


4 egrep 高级正则表达式。
.除了\t\n\r等剩下的其他字符。
\d数字
\D非数字
\s空格
\S非空格
\w字符
\W非字符
(?=...) Positive lookahead
(?!...) Negative lookahead.

 

5 写个Shell脚本运行同步程序。
在Linux下运行Java(注意用冒号来分割,并且将cp括起来,linux下分号表示命令结束,需要另起一行)
java -cp "WEB-INF/classes:WEB-INF/lib/common-logging-1.2.4.java" com.taobao.jirautil.SyncMain

 

6 Linux下设置环境变量
PATH="PATH":~/bin
export PATH


7 数值计算
total=$((aa*bb))//记得中间没有任何空格分割
8 使用test -参数来判断
#1 test string
test -z $fileName && echo "you MUST input a filename." && exit 0
#2 test fileName
test ! -e $fileName && echo "the file $fileName MUST exist." && exit 0
#3 find file property
test -f $fileName && fileType="file"
test -d $fileName && fileType="directory"
test -r $fileName && perm="readable"
test -w $fileName && perm="$perm writable"
test -x $fileName && perm="$perm excutable"
echo "$fileName is a $fileType,the permission is $perm"


7 Shell命令。
kill -KILL(必杀) PID
netstat -antp
all numeric trimming program

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics