目前分類:Shell programming (12)

瀏覽方式: 標題列表 簡短摘要
#!/bin/bash

count=0
while [ true ]
do
        count=$(( $count+1 ))
        echo $count
        if [ $count -eq 10 ];then
                break
        fi
        sleep 1
done


JerryCheng 發表在 痞客邦 留言(0) 人氣()

#!/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) 人氣()

In Shell programming , we should use $(( )) if we want to do arithmetic operation.

for example :

JerryCheng 發表在 痞客邦 留言(0) 人氣()

Sometimes , we may want to concantenate two string into one string.

It is simple in Shell programming , the example is as below:

JerryCheng 發表在 痞客邦 留言(0) 人氣()

This example tells us how to extract sub string from a long string.

 

JerryCheng 發表在 痞客邦 留言(0) 人氣()

if we want to read file's content line by line , 

we can use the shell code as below:

JerryCheng 發表在 痞客邦 留言(0) 人氣()

cv=1

if [ cv -eq 1 ];then

文章標籤

JerryCheng 發表在 痞客邦 留言(0) 人氣()

grep Accuracy inputFile

其中Accuracy表示我們想要從inputFile中尋找的關鍵字 , 

JerryCheng 發表在 痞客邦 留言(0) 人氣()

var1="string1"

var2="string2"

JerryCheng 發表在 痞客邦 留言(0) 人氣()

for i in `seq 1 1 100`

do

JerryCheng 發表在 痞客邦 留言(0) 人氣()

for i in 1 2 3

do

JerryCheng 發表在 痞客邦 留言(0) 人氣()

Attention: 在shell中不可以隨便空格

 

JerryCheng 發表在 痞客邦 留言(0) 人氣()