ChinaUnix.net
相关文章推荐:

shell 字符串函数

哟没有好的用shell返回字符串的方法? 用echo方法不好用阿, function f() { } a=`f` 这么每次用变量a的时候函数都运行一次, 我想 vimdiff ../new_dir/$a ../old_dir/$a 这样就变成 vimdiff四个文件了,而不是两个 大家有没有好的办法?为什么shell函数的支持这么弱呢?

by jazeltq - Shell - 2011-11-25 11:00:10 阅读(8721) 回复(11)

相关讨论

写了个函数 #!/bin/sh function getTime { Time=`time` return $Time } getTime CurrentTime=$? echo CurrentTime=$CurrentTime 想让他返回字符串Time,但是运行结果却是0,我怎么才能在shell函数中返回字符串呢? >test1.sh real 0m0.000s user 0m0.000s sys 0m0.000s CurrentTime=0

by icetown - Shell - 2011-07-22 15:56:58 阅读(20681) 回复(4)

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

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

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 阅读(5266) 回复(21)

shell 里有没有取得字符串长度的函数

by hxl - Shell - 2010-07-27 22:12:50 阅读(2214) 回复(8)

sort不行的 它是针对文件的

by 越野横行 - Shell - 2003-06-24 13:53:06 阅读(2378) 回复(4)

shell有判断变量是否为整型,字符,字符串等的函数吗?

by xwmhmily - Shell - 2008-07-08 11:50:19 阅读(6375) 回复(5)

#6.sh length_check() { _STR=$1 _MAX=$2 _LENGTH=`echo $_STR | awk '{print length($0)}'` if [ "$_LENGTH" -gt "$_MAX"]; then return 1 else return 0 fi } length_check 提示if [ "$_LENGTH" -gt "$_MAX"]; then 这一行错误:[: 0: unary operator expected

by maple412 - Shell - 2014-03-31 14:16:04 阅读(1677) 回复(4)

本帖最后由 myaegean 于 2011-04-05 09:32 编辑 【脚本】 -------------------------------------------------------------------- #!/bin/bash # using the return command in a function dbl() { read -p "Enter a value: " value echo "doubling the value" return $[ $value * 2 ] } result='dbl' echo "The new value is $result" -------------------------------------------------------------------- ...

by myaegean - Shell - 2011-06-16 20:23:31 阅读(3255) 回复(7)

例如 str ="abcd"现在要反转显示为dcba,有没有内置函数可以实现此功能呀?

by lrh_0_2000 - Shell - 2007-04-17 19:18:50 阅读(2124) 回复(3)

我的shell函数只能有一个参数$1, #!/bin/sh myfun () { if [ $# -ne 1 ]; then echo "please input one parameter" exit 1 fi echo $1 } string="good good" myfun $string #结束了 我运行我的脚本时出错了,程序判断成有两个参数了。请各位兄弟帮我看一下,先谢谢了。 [ 本帖最后由 cdma313 于 2006-10-17 21:39 编辑 ]

by cdma313 - Shell - 2006-10-23 17:26:53 阅读(9594) 回复(5)