ERROR_FLAG_LIST[0]='Connection timed out' ERROR_FLAG_LIST[1]='Not connected' 想通过这种方式定义数组,然后再这样: echo ${error_flag_string} grep ${error_flag_string} $LOG_PATH/$LOG_FILE > /dev/null 可是打印却是这样: Connection timed out Not connected Connection timed out Not connected 大神指教,为什么 'Connection timed out' 不是作为一个完整字符串存在,被切割了? 我想让它...
shell 字符串数组处理 -------------------------------------------------------------------------------- 这段代码用来处理系统中的某个程序(脚本)的调用,但是又不知道这个程序文件的具体位置,只是知道可能存在的位置。有点智能的味道哦。 -------------------------------------------------------------------------------- exp_cmds="$BASE_DIR/$old_version/bin/exp_my_db \ $BASE_DIR/$old_version/bin/...
1.# **|uniq -c 1 1 1 9 1 36 1 69 1 76 2. 把这些值付给数组,然后调用数组元素运算。 这样的东西在shell写如何写 这个在perl用hash比较容易,在shell中不知道如何做了 [ 本帖最后由 huanghaojie 于 2009-2-18 15:04 编辑 ]
[color="#000000"]$ A=(a b c def)EybLinux联盟 EybLinux联盟 ==================================================EybLinux联盟 $ echo ${A[@]} //取全部元素EybLinux联盟 a b c defEybLinux联盟 EybLinux联盟 =================================================EybLinux联盟 EybLinux联盟 $ echo ${A[0]} //取第一个元素EybLinux联盟 aEybLinux联盟 EybLinux联盟 =================================================EybLinux联...
shell数组 Bash中还可以使用数组变量,其赋值有两种: (1) name = (value1 ... valuen) 此时下标从0开始 (2) name[index] = value 数组下标的范围没有任何限制,同时也不必使用连续的分量. -------------------------------------------------------------------------------- $ A=(a b c def) ================================================== $ echo ${A[@]} //取全部元素 a b c def =========================================...
#!/bin/bash A=(a b c def) echo ${A[@]} //取全部元素 echo ${A[0]} //取第一个元素 echo ${#A[@]} //取得元素3的长度 echo ${#A} //取得元素3的长度 echo ${#A[3]} //取得元素3的长度 A[3]=ghb //将第三个元素重新赋值 echo ${A[@]} $ echo ${A[@]} 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/11765/showart_312287.html
请教各位高手:
有文件tmp.txt:
jhgdhfgjhdfjkg => hdfghkjdhfg
hfghdjfhgkjdh => hfgjhdkjfhgkj
我欲将$1即第一个域中的字符循环读入数组a中
然后 echo "$a" 循环显示出来
用while read line
do
for i;do
a=awk '{print $1}'
echo "$a"
done
done<