Chinaunix

标题: How to store multi-line output into an array in ksh93 [打印本页]

作者: wawxdyy    时间: 2010-10-28 15:41
标题: How to store multi-line output into an array in ksh93
Sorry, input method doesn't work, the following method doesn't work for me

  1. root@solaris:~# testarray=( $(find .) )  
  2. root@solaris:~# echo ${testarry[@]}

  3. root@solaris:~#
复制代码

作者: wawxdyy    时间: 2010-10-28 15:44
Never mind, it works actually.
作者: o绝对新手o    时间: 2010-10-28 15:56
回复 1# wawxdyy


    你这是bash的写法,KSH应该这样
   set -A arrary $(find .)
作者: wawxdyy    时间: 2010-10-28 16:08
Another question, when there are multiple columns in the output, how to get each whole line assigned to array element rather than each word.
作者: wawxdyy    时间: 2010-10-28 16:11
回复 3# o绝对新手o


    yes, you are right, thanks.
作者: o绝对新手o    时间: 2010-10-28 16:25
回复 4# wawxdyy


    对于多个列,你可以用引号把这行引用起来就可以了




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2