ChinaUnix.net
相关文章推荐:

shell字符串处理函数

text a,d,c d,d,d ============================ while read $line a = $(echo $line | awk -F; '{print $1}' ) b = $(echo $line | awk -F; '{print $2}' ) c = $(echo $line | awk -F; '{print $3}' ) echo "processing......" doneshell本身有没有字符串处理函数

by ccnuliu - Shell - 2011-12-15 22:58:09 阅读(4960) 回复(21)

相关讨论

shell字符串处理函数 如SC001 1 我需要利用函数取最后3位 2 我需要利用函数 将这个字符串转华为 小写 的 如 sc001

by liyihongcug - Shell - 2009-12-02 19:43:21 阅读(4238) 回复(2)

我有一个文本 类似 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,这个应该怎么写? 谢谢~

by lilyok12345 - Shell - 2014-10-17 15:28:12 阅读(1982) 回复(11)

突然想用shell写个像结构体那样子的数组,就是在数组里放置好多字符串。 我自己试验了一下 str=( "IP address" "Local directory" "remote directory" ) 按照上面的做法,通过${#str} 得到的值是10,不是我想要的3。 这应该怎么才能获取正确的值。

by 一世缥缈 - Shell - 2014-06-18 14:13:46 阅读(10192) 回复(6)

[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...

by hmchzb19 - Shell - 2013-11-18 16:56:30 阅读(2267) 回复(4)

本帖最后由 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:...

by gigglesun - Shell - 2013-05-20 22:29:15 阅读(1391) 回复(6)

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...

by wilsonwong - Linux文档专区 - 2008-05-27 22:50:22 阅读(808) 回复(0)

怎么样让字符串有特定长度 比如说: a="aaaaa" b="cccccc" 但是我想让a和b都有10个长度不足的用空格代替 if 判断长度 在加上长度 但是怎么加上特定长度的空格呢? 有没有 其他方法呢?

by Piaomiao139 - Shell - 2014-09-04 17:03:35 阅读(1256) 回复(9)

shell下面执行命令gluster volume info,得到的结果如下: Volume Name: volume1 Type: Distribute Volume ID: 6304e435-9856-4503-b0a8-161a12f11181 Status: Started Number of Bricks: 1 Transport-type: tcp Bricks: Brick1: 192.168.2.12:/mnt/zhanshen_vol1 Volume Name: volume_test Type: Distribute Volume ID: 0cb10e77-6c79-4c4d-b6bc-7256389edfa9 Status: Started Number of Bricks: 4 Transport-type: tcp Bricks:...

by liaolifang3301 - Shell - 2014-08-26 16:07:53 阅读(2485) 回复(14)

本帖最后由 webdna 于 2013-06-18 20:32 编辑 想对域名进行混编得到类似mydomain.com_sdfewraewfgkpo 这样的形式,为什么以下的代码不对呢? domain="mydomain.com" domain1="$domain"|md5sum|cut -c1-10 domain2="$domain_$domain1" echo domain2

by webdna - Shell - 2013-06-19 13:30:56 阅读(1032) 回复(3)

#!/bin/sh $str=123a567 $res=`expr $str : '\(.*\)a\(.*\)'` 如何获得第一个和第二个匹配

by ciedecem - Shell - 2013-04-08 22:25:14 阅读(3933) 回复(13)