PIXNET Logo登入

KwCheng's blog

跳到主文

Blog for Computer Science ...

部落格全站分類:圖文創作

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 4月 22 週二 201410:11
  • shell - while loop

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

  • 個人分類:Shell programming
▲top
  • 4月 22 週二 201410:09
  • expect - sftp example

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

  • 個人分類:Shell programming
▲top
  • 2月 27 週一 201212:15
  • Shell - Arithmetic operation

In Shell programming , we should use $(( )) if we want to do arithmetic operation.
for example :
 
a=10
(繼續閱讀...)
文章標籤

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

  • 個人分類:Shell programming
▲top
  • 2月 27 週一 201211:06
  • Shell - String concatenation

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)

  • 個人分類:Shell programming
▲top
  • 1月 21 週六 201221:09
  • Shell - Extract substring

This example tells us how to extract sub string from a long string.
 
while read stringLine
do
(繼續閱讀...)
文章標籤

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

  • 個人分類:Shell programming
▲top
  • 1月 21 週六 201221:05
  • Shell - Read file line by line

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)

  • 個人分類:Shell programming
▲top
  • 12月 29 週四 201100:46
  • Shell - if then .. else..fi

cv=1
if [ cv -eq 1 ];then
echo '$cv is equal to 1'
else
(繼續閱讀...)
文章標籤

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

  • 個人分類:Shell programming
▲top
  • 12月 29 週四 201100:42
  • Shell - grep , 尋找file中的關鍵字

grep Accuracy inputFile
其中Accuracy表示我們想要從inputFile中尋找的關鍵字 , 
若在inputFile中找到關鍵字的話 , 
(繼續閱讀...)
文章標籤

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

  • 個人分類:Shell programming
▲top
  • 12月 28 週三 201123:49
  • Shell - echo two variables

var1="string1"
var2="string2"
echo "$var1 , $var2"
(繼續閱讀...)
文章標籤

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

  • 個人分類:Shell programming
▲top
  • 12月 28 週三 201123:27
  • Shell - for loop from 1 to 100

for i in `seq 1 1 100`
do
echo $i
done
(繼續閱讀...)
文章標籤

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

  • 個人分類:Shell programming
▲top
12»

個人資訊

JerryCheng
暱稱:
JerryCheng
分類:
圖文創作
好友:
累積中
地區:

熱門文章

  • (34,773)Cpp - ifstream (read file) - 開檔 & 讀檔
  • (9,416)notepad++ - 使用notepad++對文字進行轉碼
  • (1,510)Java - 取string的每一個字
  • (444)Mathematics - 判斷point是否在triangle內
  • (407)Mablab - Histogram 調整x軸
  • (128)Matlab - 內建變數
  • (66)Solaris - svcs command
  • (52)Java - create directory
  • (48)cpp - cerr , cout , and redirect
  • (15)cpp - static member variables

文章分類

toggle Software (5)
  • Notepad++ (1)
  • Graphviz (0)
  • Windows (1)
  • Eclipse (8)
  • Sloaris (5)
toggle Programming (11)
  • my_c_lib (7)
  • Shell programming (12)
  • C / Cpp (75)
  • Python (9)
  • Html/CSS (2)
  • JavaScript (18)
  • JSP (4)
  • Matlab (13)
  • PHP (1)
  • SQL (7)
  • Java (59)
toggle Information Retrieval (2)
  • Information Retrieval (7)
  • IR - Lemur (2)
  • Solaris (3)
  • Mathematics (4)
  • computer science (4)
  • Linux (17)
  • Statistics (1)
  • 未分類文章 (1)

最新文章

  • python - time
  • python - thread
  • Javascript - class
  • shell - while loop
  • expect - sftp example
  • javascript injection
  • [轉錄] ls color setting
  • python - inheritance & template pattern
  • sorting by value of dictionary
  • Browse all elements of array

最新留言

  • [18/03/13] 琰王 於文章「Javascript - 判斷字串中是否...」留言:
    很舊的文章 但還是得糾正 不等於null為true 就...
  • [14/04/21] mahesh 於文章「Java - 執行外部指令(cmd)...」留言:
    Learn java with interview ques...
  • [12/12/12] angus4003 於文章「Javascript - Control...」發表了一則私密留言
  • [12/12/11] angus4003 於文章「Javascript - Control...」發表了一則私密留言
  • [12/12/10] angus4003 於文章「Javascript - Control...」發表了一則私密留言
  • [12/12/07] angus4003 於文章「Javascript - Control...」發表了一則私密留言
  • [12/12/07] angus4003 於文章「Javascript - Control...」發表了一則私密留言
  • [12/12/07] angus4003 於文章「Javascript - Control...」發表了一則私密留言
  • [12/12/07] angus4003 於文章「Javascript - Control...」發表了一則私密留言
  • [12/12/07] angus4003 於文章「Javascript - Control...」發表了一則私密留言

動態訂閱

文章精選

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: