#!/bin/bash
count=0
while [ true ]
do
count=$(( $count+1 ))
echo $count
if [ $count -eq 10 ];then
break
fi
sleep 1
done
JerryCheng 發表在 痞客邦 留言(0) 人氣(12)
#!/opt/csw/bin/expect
set timeout 20
spawn sftp root@host
expect "*password*"
send "ej03xu35k3au4a83\r"
expect "*sftp*"
send "cd /usr/bin/\r"
expect "*sftp*"
send "put rsync\r"
expect "*sftp*"
send "exit\r"
interact
JerryCheng 發表在 痞客邦 留言(0) 人氣(172)
In Shell programming , we should use $(( )) if we want to do arithmetic operation.
for example :
a=10
JerryCheng 發表在 痞客邦 留言(0) 人氣(6)
Sometimes , we may want to concantenate two string into one string.
It is simple in Shell programming , the example is as below:
a=string1_
JerryCheng 發表在 痞客邦 留言(0) 人氣(16)
This example tells us how to extract sub string from a long string.
while read stringLine
do
JerryCheng 發表在 痞客邦 留言(0) 人氣(20)
if we want to read file's content line by line ,
we can use the shell code as below:
while read fileContent
JerryCheng 發表在 痞客邦 留言(0) 人氣(32)
cv=1
if [ cv -eq 1 ];then
echo '$cv is equal to 1'
else
JerryCheng 發表在 痞客邦 留言(0) 人氣(56)
grep Accuracy inputFile
其中Accuracy表示我們想要從inputFile中尋找的關鍵字 ,
若在inputFile中找到關鍵字的話 ,
JerryCheng 發表在 痞客邦 留言(0) 人氣(1,057)
var1="string1"
var2="string2"
echo "$var1 , $var2"
JerryCheng 發表在 痞客邦 留言(0) 人氣(21)
for i in `seq 1 1 100`
do
echo $i
done
JerryCheng 發表在 痞客邦 留言(0) 人氣(64)