かなり無理があるが、一応使える。(笑
#!/bin/sh # 2008.06.25 h.kameda # get_ini.sh [file] [section] [keyword] if [ "$1" = "" -o "$2" = "" -o "$3" = "" ]; then echo "usage : get_ini.sh [file] [section] [keyword]" exit 0 fi sw=0 while read F1 do tmp=`echo $F1 | awk /]/'{print $1}'` if [ "$tmp" != "" ]; then str=`echo $tmp | awk -F[ '{print $2}' | awk -F] '{print $1}'` if [ "$str" = "$2" ]; then sw=1 else sw=0 fi fi if [ "$sw" = "1" ]; then profile=`echo $F1 | grep $3 | awk -F= '{print $2}' | awk -F; '{print $1}'` keyword=`echo $F1 | grep $3 | awk -F= '{print $1}'` if [ "$profile" != "" ]; then if [ "$keyword" = "$3" ]; then echo $profile break fi fi fi done < $1