Shell Scripts 구문

IBM Power 2011. 11. 16. 13:54
#!/bin/sh
### ---
if [[ $# -ne 3 ]]
then
   echo 'Usage: aShell.sh <logname> <interval:second> <duration:minute>'
   # exit
fi
### ---
if [[ $1 -lt 5 ]]
then
   echo 'args[1] is smaller than 5'
   # exit
fi

### ---
cd /home
for home in *
        do echo "- ${home} ---"
        ls -alrt ${home}
done
### ---
hostnm=`hostname`
if [ `hostname` = "localhost" ]
then
        echo "changed hostname with 'smitty hostname'"
elif [ `hostname` = "apple" ]
then
        echo "hostname is apple"
else
        echo "hostname is "${hostnm}
fi

### ---
DATE=`date +"%y%m%d_%H%M"`
### ---
ins=1
inx=3
while [ ${ins} -le 5 ]
do
        echo "while looping " ${inx}
        sleep 1
        (( ins=${ins}+1 ))
        inx=${inx}+1
        echo ${ins}  "   " ${inx}
done
echo ">>>>>>>>>>>>>>>>"
print ${inx}
unset inx
echo "---"
print ${inx}
echo ">>>>>>>>>>>>>>>>"
### ---
read proceed?"proceed? (y/n)"
if [[ ${proceed} == "n"  || ${proceed} == "N" ]]
then
        echo "stop"
        exit
fi
echo "proceed"
 
### ---
initial_count=1
max_count=5
while (( ${initial_count} <= ${max_count} ))
do
        (( initial_count = ${initial_count} + 1 ))
done
echo ${initial_count}
### ---
# if [[ $# -ne 2 ]]
# then
#       echo 'Usage: rmhdisk.sh <hdisk#-start> <hdisk#-end>'
#       exit
# fi
# i=$1
# while [ $i -le $2 ]
# do
#       echo "removing hdisk${i}"
#       rmdev -Rdl hdisk$i
#       ((i=i+1))
# done
### ---
ls -alrt  | grep -v grep | awk '{print "file " $9}' | sh -x
### ---
for oddnum in 1 3 5 7 9
do print ${oddnum}
sleep 1
done

### --- 
find /usr/bin -type f |sort | xargs ls -l | awk '{print $1 " " $NF}' > permission.txt

 


'IBM Power' 카테고리의 다른 글

CPU Folding 비활성화 (vpm_xvcpus)  (0) 2011.11.28
vios commands  (0) 2011.11.16
vi expr  (0) 2011.11.16
장착된 NIC가 UTP 타입인지 Fiber 타입인지 확인  (0) 2011.11.16
GPFS 로 Shared disk 생성 사례 #1 - (3node && no-tiebreak)  (0) 2011.11.16
블로그 이미지

Melting

,