我使用mutt发送邮件并带附件,发现有如下问题,使用脚本自动发邮件,附件的文件名中有空格等特殊字符就会发送失败,但是手工命令直接执行没有问题。 例如: mutt -s "bbb" -a "/home/mail/test123/新建 测试文件 (2).txt" "/home/mail/test123/测试文件.txt" -- [email]test123@test.com[/email] < /root/aaa.txt 直接命令行执行成功 , “bbb”是邮件主题, -a后面是邮件的附件。/root/aaa.txt是邮件正文。 但是我使用脚本就有...
by freecr_cu - Shell - 2011-12-07 14:50:59 阅读(11923) 回复(14)
写一个shell小脚本,不同文件使用不同参数过滤,grep为什么不能做为变量使用,请教各位了 #!/bin/sh g="grep -o ' ab'" cmd=`cat test| $g| sort | uniq -c` echo "$cmd" 运行报错: root@dcserver127:/tmp# ./t1.sh grep: ab': 没有那个文件或目录 怎样才能使 变量g与其它命令结合起来,多谢
本帖最后由 biubiuu 于 2015-03-10 11:50 编辑 我要更换网卡0的mac和ip,下面是/etc/network/interfaces 文件的一部分 auto eth0 iface eth0 inet static pre-up ifconfig eth0 hw ether 84:7E:40:EF:D6:C6 address 192.168.2.88 netmask 255.255.255.0 network 192.168.1.0 gateway 192.168.1.1 我是这么做的 ip=192.168.1.1 mac=01:01:01:01:01:01 sed -i -e "0,/^address/s/.*\(a...
我有一个文本 类似 8613302200008,460030902234084,1201,12,600101,2002-03-19 12:00:00,2013-06-29 22:00:50 8613302200009,460030918855095,1001,12,600101,2010-12-30 18:06:51,2011-09-12 05:30:21 我想替换第三列的值,如果是1201则替换成15 ,如果是1001则替换成10,这个应该怎么写? 谢谢~
突然想用shell写个像结构体那样子的数组,就是在数组里放置好多字符串。 我自己试验了一下 str=( "IP address" "Local directory" "remote directory" ) 按照上面的做法,通过${#str} 得到的值是10,不是我想要的3。 这应该怎么才能获取正确的值。
[code]echo $string Rolling lessons learned from Hadoop into an open source Hadoop successor [root@netuf20 home]# echo `expr match "$string" 'Hadoop'` 0 [root@netuf20 home]# echo `expr index "$string" 'R'` 1 [root@netuf20 home]# echo `expr index "$string" 'o'` 2 [root@netuf20 home]# echo `expr index "$string" 'Rolling'` 1 [root@netuf20 home]# echo `expr match "$string" 'Rolling'` 7 [root@netuf20 ho...
本帖最后由 gigglesun 于 2013-05-13 23:24 编辑 A=“fe:48:00:00:03:00:00:02:00:10:00:09:c9:03:b2:58" 转换规则: 从字符串首开始,每5个字符为一组,组之间“:”保留,如fe:48为一组, 第二组为00:00....最后一组为b2:58。每组中冒号去掉,从左到右后连续的0去掉,如全部为0,保留一个0,如:[code] fe:48->fe48 00:00->0 03:00->300 00:02->2 00:10->10 00:09->9 c9:03->c903 b2:58->b258 [/code]转换后: B="fe48:...
shell字符串处理 2007-06-09 23:39 shell字符串处理 构造字符串 直接构造 STR_ZERO=hello STR_FIRST="i am a string" STR_SECOND='success' 重复多次 #repeat the first parm($1) by $2 times strRepeat() { local x=$2 if [ "$x" == "" ]; then x=0 fi local STR_TEMP="" while [ $x -ge 1 ]; do STR_TEMP=`printf "%s%s" "$STR_TEMP" "$1"` x=`expr $x - 1` done echo $STR_TEMP } 举例: STR_REPEAT=`strRepeat "$USER_NAME" 3...
求助,sql语句拼接,用shell脚本 目录下有1万多个txt文档,内容跟下面的格式是一样的,第一行数字为content_id 剩下的所有的全部为txt内容,现在需要些一个shell脚本拼接生sql语句,例子写在下面了。 下面附上两个文档内容 目录下的文本部分 10000.txt 10082.txt 10165.txt 10249.txt 10001.txt 10083.txt 10166.txt 10250.txt 10002.txt 10084.txt 10167.txt 10251.txt 10003.txt 10085.txt 10168.txt 1025...