2009年7月7日 星期二

shell 裡的 for 迴圈應用

#!/bin/bash

#str=$(ps axw -eo pid,command | grep "org.apache.catalina.startup.Bootstrap" | grep "start" | awk '{print $1}')

str=$(ps axw -eo pid,command |\
grep "apache" | grep "start" |\
awk '{print $1}')
echo "str = $str"

count=1
for i in $str
do
echo "string[$count]= $i"
count=$(($count+1))
done

0 意見: