shell编程
venceinfo
这个作者很懒,什么都没留下…
展开
-
shell小结(1)
-----samba服务器://连接对方共享的共享,这个用户名是对方提供的,效果相当于ftp,如果对方机器开启了guest用户,则//不用输入用户名smbclient //机器名/共享目录 -U 用户名//将window上的磁盘挂载到本机linux上的某一个目录下//这里的uid,gid是linux用户的uid,gid,必须指定,否则这里的y:会访问不了mount -t smbfs -o username=gkf14930,uid=9909,gid=100,i原创 2009-12-30 16:26:03 · 75 阅读 · 0 评论 -
linux好文章
2010-03-26 10:12:55 · 66 阅读 · 0 评论 -
shell小结(15)
1>> ok.log 2>> fail.logfi-------------------------------------------------------------------------------------------#!/bin/bashread -p "enter your name?" nameread -p "enter your age?" ageecho原创 2010-02-09 15:33:44 · 74 阅读 · 0 评论 -
shell小结(14)
-----------------------#如何取得本机的IP:auto_get_IP(){ HOSTNAME=`hostname` myIp=`grep $HOSTNAME /etc/hosts | grep -v "^#" | head -1 | awk '{print $1}'`}head -1 显示第1行 等价于:head -n 1-----------------------------------------------原创 2010-02-05 14:10:43 · 53 阅读 · 0 评论 -
shell小结(13)
ie "not enough space in ${check_dir} (need:${need_space}M available:${avail}M)"}-------------------------------------------------------------------------------------------#利用root用户执行,得到oracle的版本su - oracle -c "sqlplus -version"原创 2010-02-05 14:09:59 · 70 阅读 · 0 评论 -
shell小结(12)
-----------------//比较运算的另一种方式[[]]#!/bin/bashtypeset -i count=1if [[ 1 < 2 ]];then count=`expr $count+1` echo $countfi-------------------------------------------------------------------------------------------#!/bin/bash原创 2010-01-21 15:20:50 · 46 阅读 · 0 评论 -
shell小结(11)
st.sql" | slqplus sytem/system@lbs-------------------------------------------------------------------------------------------### 此段代码用于保证可使用相对路径,不要删除 ###if [ `echo $0 | grep -c "/"` -gt 0 ]then cd ${0%/*}fi ------------------原创 2010-01-21 14:51:37 · 76 阅读 · 0 评论 -
shell小结(10)
ep' | awk '{print $2}'` p2=`ps -fu $user |grep 'tee' | grep -v 'grep' | awk '{print $2}'` p3=`ps -fu $user |grep 'idead' | grep -v 'grep' | awk '{print $2}'` PIDS=($p1 $p2 $p3) for pid in ${PIDS[@]} do if [ "X$pid"原创 2010-01-20 20:06:10 · 76 阅读 · 0 评论 -
shell小结(9)
原创 2009-12-30 17:28:25 · 54 阅读 · 0 评论 -
shell小结(8)
builtin cd-------------------------------------------------------------------------------------------echo ${UID}_It is safe to omit the curly brackets ({}) if the variable name is followed by a character that isn't a letter, digit, or underscor原创 2009-12-30 17:24:30 · 71 阅读 · 0 评论 -
shell小结(7)
#!/bin/bash{ while read line do echo $line | grep -o '${.[^${}]*}' | sed -e 's/\${//g' | sed -e 's/}//g' done } < text.txt-------------------------------------------------------------------------------------------数组:#!/bin/ba原创 2009-12-30 17:23:49 · 55 阅读 · 0 评论 -
shell小结(6)
//如果写成 for day 而没有后面的 in [list] 部分,则 day 将取遍命令行的所有参数。如这个程序:#!/bin/bashfor paramdo echo $paramdoneexit 0//循环所有参数 #!/bin/bash for i in "$@" do ehco $i done------------------------------------------------------原创 2009-12-30 17:21:40 · 54 阅读 · 0 评论 -
shell小结(5)
---------------------------------------------------------------------------function wrap{ #set -x typeset func_name="wrap" typeset ret="" #执行业务调用的脚本或者命令 $@ ret=$? return ${ret} }------原创 2009-12-30 17:18:09 · 55 阅读 · 0 评论 -
shell小结(4)
l的名字$0: awk时,代表当前的一整行--------------------------------------------------------------------------------------------在Vim 中可以直接查看文件编码:set fileencoding :set fileencoding即可显示文件编码格式。----------------------------------------------------------------原创 2009-12-30 17:17:25 · 69 阅读 · 0 评论 -
shell小结(3)
-------------------------------------------------------------------JDK的检查: if [ "x$JAVAHOME" = "x" ]; then echo "JAVAHOME环境变量未设置" exit 1 fi if [ -x $JAVAHOME/bin/java ]; then printf &qu原创 2009-12-30 17:09:46 · 56 阅读 · 0 评论 -
shell小结(2)
---------------------------------------\< 和 \> 分别标注单词的开始与结尾。 例如: grep man * 会匹配 ‘Batman’、‘manic’、‘man’等, grep '\<man' * 匹配‘manic’和‘man’,但不是‘Batman’, grep '\<man\>' 只匹配‘man’,而不是‘Batman’或‘manic’等其他的字符串。 '^':指匹原创 2009-12-30 16:58:31 · 108 阅读 · 0 评论 -
简单代码统计脚本
exit 1fifile_name=$1#总行数all_num=`sed -n "$"= $file_name`#注释行数note_num=`egrep "(^[[:space:]]*/\*)|([[:space:]]*//)" $file_name | wc -l`#空行数null_num=`grep "^[[:space:]]*$" $file_name | wc -l`echo 总行数:2013-05-25 07:00:33 · 76 阅读 · 0 评论