code
stringlengths
1
1.96M
language
stringclasses
1 value
#!/bin/sh # ip2host.sh - 從IP位址調查主機名稱 # r_host # 使用host指令來調查主機名稱 # 結果的最後一個單字就是主機名稱 r_host() { set -- `host $1` shift `expr $# - 1` case $1 in *\(NXDOMAIN\)) # 找不到時 return 1 ;; *) expr "$1" : "\(.*\)\." #主機名稱最後的「.」要拿掉 esac } # r_nslookup # 使用nslookup來調查主機名稱 # 找出有「Name: HOS...
Shell
#!/bin/sh # mail_send.sh - 整理郵件的格式,若有必要的話送出郵件 # 從標準輸入接收訊息,進行漢字碼的轉換.標頭的MIME編碼之後 # 寫到標準輸出上 # (若有指定選項「--send」的話,則送出郵件) # # 若沒有「From:」「Message-Id:」標頭的話,則把它加上去 # sendmail的「-f」選項永遠都是傳FROM_ADDRESS(在這個script中有定義)給它 # # 調查sendmail的位置 if [ -x /usr/sbin/sendmail ]; then SENDMAIL_PATH="/usr/sbin/sendmail" elif [ -x /usr/li...
Shell
#!/bin/bash #=============================================================================== # Copyright 2011 zod.yslin # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.o...
Shell
#!/bin/sh # np_client.sh - 使用FIFO的用戶端行程 PIPE=/tmp/np_server.pipe # 確認伺服器是否為執行中 if [ ! -e $PIPE ]; then # 若FIFO不存在的話,則顯示錯誤並結束 echo "np_server.sh is not running." exit 1 fi # 與伺服器連線,並確認版本 echo "SVER" >>$PIPE read code ver <$PIPE echo "Connected to np_server.sh (ver $ver)" # 將從標準輸入讀入的資料傳送給伺服器,取得單字數(要按Ctrl...
Shell
#!/bin/sh # is_host_alive.sh - 使用ping來調查指定的主機是否還活著 # Solaris以外系統中的ping的使用法 PING="ping" PING_OPT="-c 1" PING_ALIVE=' 0%' # Solaris的話,ping的使用方法有些不同 if [ -x /usr/sbin/ping ]; then PING="/usr/sbin/ping" PING_OPT="" PING_ALIVE='alive' fi # Solaris中的話「... is alive」 # 其它系統的話「..., 0% packet loss」表示指定的主機還活著 $PIN...
Shell
#!/bin/bash #=============================================================================== # Copyright 2011 zod.yslin # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.o...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: socket.sh # Description: # # Edit History: # 2010-12-16 File created. #======================================================================== #How to forcibly close a socket in TIME_...
Shell
#!/bin/bash #=============================================================================== # Copyright 2011 zod.yslin # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.o...
Shell
#!/bin/bash #=============================================================================== # Copyright 2011 zod.yslin # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.o...
Shell
#!/bin/sh # np_server.sh - 使用FIFO的伺服器行程 # 初始設定 PIPE=/tmp/np_server.pipe SVER=1 # cleanup # 結束時將FIFO刪除 cleanup() { echo "cleanup" >&2 [ -p $PIPE ] && rm $PIPE exit } # 若FIFO已存在,則顯示錯誤並結束 if [ -e $PIPE ]; then echo "Named pipe $PIPE already exist." echo "If it is sure that server is not running...
Shell
#!/bin/sh # autoresponder.sh - 自動回覆郵件 FROM_ADDRESS="query@nnip.org" TAB=`printf "\t"` # cleanup # 在shell script中斷.結束時會被呼叫的函數 cleanup() { [ -n "$temp" ] && rm $temp } # header # 抽取出指定的標頭的內容 header() { sed '/^$/q' $temp | grep -i "$1:" | sed 's/.*:[ $TAB]*\(.*\)/\1/' # 用sed將訊息的開頭到第一個空行的部分抽取出來(/^$...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: sleep.sh # Description: # # Edit History: # 2011-01-19 File created. #======================================================================== #sleep can be used in a loop to repeat a j...
Shell
#!/bin/sh # nice.sh - nice指令的範例 # do_load # 讓系統增加負荷(提高CPU使用率)的函數 do_load() { while true; do gzip -9 -c /bin/sh > /dev/null # 增加系統負荷 done } # 在背景中增加系統負荷 do_load & bgpid=$! # 用不同的nice值去執行程式 time nice -n 0 gzip -9 -c /bin/sh > /dev/null time nice -n 10 gzip -9 -c /bin/sh > /dev/null time nice -n 20 gzip...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: xargs.sh # Description: # # Edit History: # 2011-01-18 File created. #======================================================================== #-n表示最多把多少個資料送給cat處理,這邊一次只cat一個檔案 ls -l ...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: eval.sh # Description: # 重新運算字串並且執行,類似sql injection的感覺, command injection的一種 # # - # Edit History: # 2011-04-29 File created. #========================================================...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: backtick.sh # Description: # 執行方法有 # `command` # "command" # $(command) # (command) # {command} # eval "$command" # Edit History: # 2011-02-25 File created. #=========...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: process.sh # Description: # # Edit History: # 2010-12-21 File created. #======================================================================== #shell script不會顯現,要再一般模式下執行 #disable the...
Shell
#!/bin/sh # ulimit.sh - ulimit的範例 # 限制CPU時間 ulimit -t 1 # 永遠重複複雜的計算 i=1 while true; do i=`expr $i \* -5 + 20` echo "$i" done
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: subshell.sh # Description: # # Edit History: # 2011-04-30 File created. #======================================================================== # [A] 在背景中執行make與make install # (只...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: process.sh # Description: # # Edit History: # 2010-12-21 File created. #======================================================================== #shell script不會顯現,要再一般模式下執行 #disable the...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: sleep.sh # Description: # # Edit History: # 2011-01-19 File created. #======================================================================== #sleep can be used in a loop to repeat a j...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: eval.sh # Description: # 重新運算字串並且執行,類似sql injection的感覺, command injection的一種 # # - # Edit History: # 2011-04-29 File created. #========================================================...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: subshell.sh # Description: # # Edit History: # 2011-04-30 File created. #======================================================================== # [A] 在背景中執行make與make install # (只...
Shell
#!/bin/sh # ulimit.sh - ulimit的範例 # 限制CPU時間 ulimit -t 1 # 永遠重複複雜的計算 i=1 while true; do i=`expr $i \* -5 + 20` echo "$i" done
Shell
#!/bin/sh # wait.sh - 等待子行程結束 # 將這個函數當成子行程(subshell)來執行 sub_process() { echo "Sub-process: start" sleep 5 echo "Sub-process: end" } sub_process & # 在背景執行子行程 wait $! # 等候子行程結束 echo "Finished!"
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: backtick.sh # Description: # 執行方法有 # `command` # "command" # $(command) # (command) # {command} # eval "$command" # Edit History: # 2011-02-25 File created. #=========...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: xargs.sh # Description: # # Edit History: # 2011-01-18 File created. #======================================================================== #-n表示最多把多少個資料送給cat處理,這邊一次只cat一個檔案 ls -l ...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: group.sh # Description: # # Edit History: # 2011-04-29 File created. #======================================================================== # grouping.sh - grouping的例子 # 使make與make ...
Shell
#!/bin/sh # nice.sh - nice指令的範例 # do_load # 讓系統增加負荷(提高CPU使用率)的函數 do_load() { while true; do gzip -9 -c /bin/sh > /dev/null # 增加系統負荷 done } # 在背景中增加系統負荷 do_load & bgpid=$! # 用不同的nice值去執行程式 time nice -n 0 gzip -9 -c /bin/sh > /dev/null time nice -n 10 gzip -9 -c /bin/sh > /dev/null time nice -n 20 gzip...
Shell
#!/bin/sh # forkmany.sh - 啟動很多行程 for i in 1 2 3 4 5 6 7 8 9 10; do sleep 100 & done
Shell
#!/bin/sh # wait.sh - 等待子行程結束 # 將這個函數當成子行程(subshell)來執行 sub_process() { echo "Sub-process: start" sleep 5 echo "Sub-process: end" } sub_process & # 在背景執行子行程 wait $! # 等候子行程結束 echo "Finished!"
Shell
#!/bin/sh # forkmany.sh - 啟動很多行程 for i in 1 2 3 4 5 6 7 8 9 10; do sleep 100 & done
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: group.sh # Description: # # Edit History: # 2011-04-29 File created. #======================================================================== # grouping.sh - grouping的例子 # 使make與make ...
Shell
#!/bin/bash # arith_bash.sh - bash的四則運算 x=5 y=9 z=13 # 與expr的時候不一樣,不需將特殊符號用「\」來做脫逸(escape) # 變數前的「$」也可以省略 a=$(( x*y )) b=$(( (y+z)/x )) echo "$a" echo "$b"
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: bc.sh # Description: # # Edit History: # 2011-01-19 File created. #======================================================================== bc <<eof scale=4 8/3 2.6666 2.5 * 4.1/6.9 1.4...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: expr.sh # Description: # expr integer1 operand integer2 # # Operand Description # + Addition # - Subtraction # \* Multiplication # / Integer division (any fraction in the r...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: random.sh # Description: # # -random_bash - 使用bash的RANDOM變數來取得亂數 # -random - 使用ruby來產生亂數 # Edit History: # 2011-04-30 File created. #==============================================...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: expr.sh # Description: # expr integer1 operand integer2 # # Operand Description # + Addition # - Subtraction # \* Multiplication # / Integer division (any fraction in the r...
Shell
#!/bin/sh # float.sh - 使用bc的浮點數運算 # 定義shell變數 A=5 B=7 # 若沒有設定scale的話,小數點以下會被捨去 echo 'scale=5; sqrt(1/3)' | bc # 也可以使用here document來寫 bc <<EOF scale=3 ($A + 2) * $B / 11 EOF
Shell
#!/bin/sh # bulkycalc.sh - 一次進行多個計算 # 輸入檔中每行寫一個計算式。bc會從標準輸入逐行取得算式,並計算之。 # 結果會被存在暫存檔中。 # 最後用paste將輸入檔和結果做結合 # 若引數的個數不正確的話,則顯示使用說明 if [ $# -ne 1 ]; then echo "usage: bulkycalc.sh input-file" exit 1 fi # 製作暫存檔 temp=`mktemp /tmp/bulkycalc.XXXXXXXX` || exit 1 cat "$1" | bc > "$temp" # 進行計算 paste -d = "$1" "$te...
Shell
#!/bin/bash # arith_bash.sh - bash的四則運算 x=5 y=9 z=13 # 與expr的時候不一樣,不需將特殊符號用「\」來做脫逸(escape) # 變數前的「$」也可以省略 a=$(( x*y )) b=$(( (y+z)/x )) echo "$a" echo "$b"
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: random.sh # Description: # # -random_bash - 使用bash的RANDOM變數來取得亂數 # -random - 使用ruby來產生亂數 # Edit History: # 2011-04-30 File created. #==============================================...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: bc.sh # Description: # # Edit History: # 2011-01-19 File created. #======================================================================== bc <<eof scale=4 8/3 2.6666 2.5 * 4.1/6.9 1.4...
Shell
#!/bin/sh # bulkycalc.sh - 一次進行多個計算 # 輸入檔中每行寫一個計算式。bc會從標準輸入逐行取得算式,並計算之。 # 結果會被存在暫存檔中。 # 最後用paste將輸入檔和結果做結合 # 若引數的個數不正確的話,則顯示使用說明 if [ $# -ne 1 ]; then echo "usage: bulkycalc.sh input-file" exit 1 fi # 製作暫存檔 temp=`mktemp /tmp/bulkycalc.XXXXXXXX` || exit 1 cat "$1" | bc > "$temp" # 進行計算 paste -d = "$1" "$te...
Shell
#!/bin/sh # float.sh - 使用bc的浮點數運算 # 定義shell變數 A=5 B=7 # 若沒有設定scale的話,小數點以下會被捨去 echo 'scale=5; sqrt(1/3)' | bc # 也可以使用here document來寫 bc <<EOF scale=3 ($A + 2) * $B / 11 EOF
Shell
#!/bin/sh # xyesno.sh - 在GUI中詢問Yes/No if Xdialog --yesno "Are you sure?" 8 70; then echo "Your answer was YES." else echo "Your answer was NO." fi
Shell
#!/bin/sh # xsimpleedit.sh - 簡單的文字編輯器 # 啟動時需指定欲編輯的檔名。選擇「OK」之後,會在經過使用者的同意之後 # 將檔案儲存起來。若按下「Cancel」 # 則會在未儲存的情況下結束程式 if ! [ -f "$1" ]; then echo "usage: xsimpleedit.sh filename" exit 1 fi tmp=`mktemp /tmp/xdialog.XXXXXXXX` || exit 1 if Xdialog --editbox "$1" 25 80 2>"$tmp"; then if Xdialog --yesno "Are you...
Shell
#!/bin/sh # xpager.sh - 若沒有指定檔名的話,則顯示 # 選擇檔案用的對話盒 if [ -z "$1" ]; then fname=`Xdialog --stdout --fselect ./ 25 60` || exit 1 else fname="$1" fi Xdialog --no-cancel --textbox "$fname" 25 80
Shell
#!/bin/sh # xmenu_dlg.sh - 在GUI中從多個項目做選擇 while true; do result=`Xdialog --stdout --no-tags --menubox \ "Which fruits do you like?" 11 70 4 \ A "Apples" O "Oranges" B "Bananas" X "I'm full!"` [ $? -ne 0 ] && break case "$result" in X) break 2;; # 跳出while迴圈 A) fruit="apples";; O) ...
Shell
#!/bin/sh # xyesno.sh - 在GUI中詢問Yes/No if Xdialog --yesno "Are you sure?" 8 70; then echo "Your answer was YES." else echo "Your answer was NO." fi
Shell
#!/bin/sh # xmsgbox.sh - 用GUI來顯示訊息 Xdialog --msgbox "Hello, world!" 6 60
Shell
#!/bin/sh # xinputbox.sh - 在GUI中取得1行的輸入 answer=`Xdialog --stdout --inputbox "May I have your name, please?" \ 8 70 "Anonymous Coward"` Xdialog --msgbox "Your name is $answer" 8 70
Shell
#!/bin/sh # xinputbox.sh - 在GUI中取得1行的輸入 answer=`Xdialog --stdout --inputbox "May I have your name, please?" \ 8 70 "Anonymous Coward"` Xdialog --msgbox "Your name is $answer" 8 70
Shell
#!/bin/sh # xsimpleedit.sh - 簡單的文字編輯器 # 啟動時需指定欲編輯的檔名。選擇「OK」之後,會在經過使用者的同意之後 # 將檔案儲存起來。若按下「Cancel」 # 則會在未儲存的情況下結束程式 if ! [ -f "$1" ]; then echo "usage: xsimpleedit.sh filename" exit 1 fi tmp=`mktemp /tmp/xdialog.XXXXXXXX` || exit 1 if Xdialog --editbox "$1" 25 80 2>"$tmp"; then if Xdialog --yesno "Are you...
Shell
#!/bin/sh # xpager.sh - 若沒有指定檔名的話,則顯示 # 選擇檔案用的對話盒 if [ -z "$1" ]; then fname=`Xdialog --stdout --fselect ./ 25 60` || exit 1 else fname="$1" fi Xdialog --no-cancel --textbox "$fname" 25 80
Shell
#!/bin/sh # xmsgbox.sh - 用GUI來顯示訊息 Xdialog --msgbox "Hello, world!" 6 60
Shell
#!/bin/sh # xmenu_dlg.sh - 在GUI中從多個項目做選擇 while true; do result=`Xdialog --stdout --no-tags --menubox \ "Which fruits do you like?" 11 70 4 \ A "Apples" O "Oranges" B "Bananas" X "I'm full!"` [ $? -ne 0 ] && break case "$result" in X) break 2;; # 跳出while迴圈 A) fruit="apples";; O) ...
Shell
#!/bin/sh # menu_dlg.sh - 使用純文字對話盒讓使用者從選單做選擇 tmp=`mktemp /tmp/dialog.XXXXXXXX` || exit 1 while true; do dialog --menu "Which fruits do you like?" 11 70 4 \ A "Apples" O "Oranges" B "Bananas" X "I'm full!" 2>"$tmp" [ $? -ne 0 ] && break case `cat "$tmp"` in X) break 2;; # 跳出while迴圈 A) fruit=...
Shell
#!/bin/sh # yesno_dlg.sh - 用純文字對話盒來詢問Yes/No dialog --yesno "Are you sure?" 8 70 result=$? if [ $result -eq 0 ]; then echo "Your answer was YES." elif [ $result -eq 1 ]; then echo "Your answer was NO." else echo "Action was cancelled." fi
Shell
#!/bin/sh # menu_dlg.sh - 使用純文字對話盒讓使用者從選單做選擇 tmp=`mktemp /tmp/dialog.XXXXXXXX` || exit 1 while true; do dialog --menu "Which fruits do you like?" 11 70 4 \ A "Apples" O "Oranges" B "Bananas" X "I'm full!" 2>"$tmp" [ $? -ne 0 ] && break case `cat "$tmp"` in X) break 2;; # 跳出while迴圈 A) fruit=...
Shell
#!/bin/sh # pager.sh - 當沒有指定檔名的時候 # 顯示選擇檔案用的對話盒 if [ -z "$1" ]; then tmp=`mktemp /tmp/dialog.XXXXXXXX` || exit 1 dialog --fselect ./ 12 60 2>"$tmp" || { rm "$tmp"; exit 1; } fname=`cat "$tmp"` rm "$tmp" else fname="$1" fi ${PAGER:-more} "$fname"
Shell
#!/bin/sh # xmsgbox.sh - 用GUI來顯示訊息 dialog --msgbox "Hello, world!" 8 70
Shell
#!/bin/sh # xmsgbox.sh - 用GUI來顯示訊息 dialog --msgbox "Hello, world!" 8 70
Shell
#!/bin/sh # pager.sh - 當沒有指定檔名的時候 # 顯示選擇檔案用的對話盒 if [ -z "$1" ]; then tmp=`mktemp /tmp/dialog.XXXXXXXX` || exit 1 dialog --fselect ./ 12 60 2>"$tmp" || { rm "$tmp"; exit 1; } fname=`cat "$tmp"` rm "$tmp" else fname="$1" fi ${PAGER:-more} "$fname"
Shell
#!/bin/sh # yesno_dlg.sh - 用純文字對話盒來詢問Yes/No dialog --yesno "Are you sure?" 8 70 result=$? if [ $result -eq 0 ]; then echo "Your answer was YES." elif [ $result -eq 1 ]; then echo "Your answer was NO." else echo "Action was cancelled." fi
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: dir.sh # Description: # # Edit History: # 2011-02-16 File created. #======================================================================== mkdir "d i r"; touch "f i l e"; echo "===d...
Shell
#!/bin/sh # grepedit.sh - 用編輯器開啟符合正規表現的那一行 # 若引數的個數不正確的話,則顯示使用說明 if [ $# -ne 2 ]; then echo "usage: grepedit.sh regexp filename" exit 1 fi regexp="$1" filename="$2" # 「rep -n」是表示以「行號:內容」的方式來顯示出找到的那一行內容的意思 # 若有找到與樣式符合的行,則行號會被存到「$1」中 # 若沒找到的話則是「NF」 IFS=':' set -- `grep -n "$regexp" "$filename" || echo 'NF'` ...
Shell
#!/bin/sh # grepedit.sh - 用編輯器開啟符合正規表現的那一行 # 若引數的個數不正確的話,則顯示使用說明 if [ $# -ne 2 ]; then echo "usage: grepedit.sh regexp filename" exit 1 fi regexp="$1" filename="$2" # 「rep -n」是表示以「行號:內容」的方式來顯示出找到的那一行內容的意思 # 若有找到與樣式符合的行,則行號會被存到「$1」中 # 若沒找到的話則是「NF」 IFS=':' set -- `grep -n "$regexp" "$filename" || echo 'NF'` ...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: dir.sh # Description: # # Edit History: # 2011-02-16 File created. #======================================================================== mkdir "d i r"; touch "f i l e"; echo "===d...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: find.sh # Description: # # Edit History: # 2011-01-18 File created. #======================================================================== ##########################################...
Shell
#!/bin/sh # find_by_date.sh - 搜尋出在指定的時日被更新的檔案 # 若GNU date有被安裝為gnudate的話,則使用之 gnudate=`which gnudate` [ -z "$gnudate" ] && gnudate="date" # cleanup # 若script被中斷.結束時,則會執行這個函數 cleanup() { [ -n "$start_tmp" ] && rm "$start_tmp" [ -n "$end_tmp" ] && rm "$end_tmp" } # 若引數的數目不對的話,則顯示使用說明 if [ $# -ne 2 ]; the...
Shell
#!/bin/sh # find_by_date.sh - 搜尋出在指定的時日被更新的檔案 # 若GNU date有被安裝為gnudate的話,則使用之 gnudate=`which gnudate` [ -z "$gnudate" ] && gnudate="date" # cleanup # 若script被中斷.結束時,則會執行這個函數 cleanup() { [ -n "$start_tmp" ] && rm "$start_tmp" [ -n "$end_tmp" ] && rm "$end_tmp" } # 若引數的數目不對的話,則顯示使用說明 if [ $# -ne 2 ]; the...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: find.sh # Description: # # Edit History: # 2011-01-18 File created. #======================================================================== ##########################################...
Shell
#!/bin/bash #=============================================================================== # Copyright 2011 zod.yslin # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.o...
Shell
#!/bin/bash #=============================================================================== # Copyright 2011 zod.yslin # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.o...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: find.sh # Description: # Find out how many file descriptors are being used # Edit History: # 2010-12-22 File created. #================================================================...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: find.sh # Description: # Find out how many file descriptors are being used # Edit History: # 2010-12-22 File created. #================================================================...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: syntax.sh # Description: # The invocation syntax for awk and sed is as follows: # command 'script' filenames # Here command is either awk or sed, script is a list of commands understood by...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: syntax.sh # Description: # The invocation syntax for awk and sed is as follows: # command 'script' filenames # Here command is either awk or sed, script is a list of commands understood by...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: delete3rdTo6thLine.sh # Description: # # Edit History: # 2011-02-24 File created. #======================================================================== sed '3,6d' line.txt
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: replaceNewLine.sh # Description: # # Edit History: # 2011-02-23 File created. #======================================================================== #old version sed 's/$/\ /' line....
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: get3rdTo6thLine.sh # Description: # # Edit History: # 2011-02-24 File created. #======================================================================== #Any line numbered greater than...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: getTheLast6Lines.sh # Description: # # Edit History: # 2011-02-24 File created. #======================================================================== #[1] : set label loop #[2] : w...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: replaceNewLine.sh # Description: # # Edit History: # 2011-02-23 File created. #======================================================================== #old version sed 's/$/\ /' line....
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: delete3rdTo6thLine.sh # Description: # # Edit History: # 2011-02-24 File created. #======================================================================== sed '3,6d' line.txt
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: get4thLine.sh # Description: # # Edit History: # 2011-02-24 File created. #======================================================================== #When sed reads Line 1 (2, 3), since...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: deleteTheLast6Lines.sh # Description: # # Edit History: # 2011-02-24 File created. #======================================================================== #Steps [1] thru [6] consti...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: getTheLast6Lines.sh # Description: # # Edit History: # 2011-02-24 File created. #======================================================================== #[1] : set label loop #[2] : w...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: deleteTheLast6Lines.sh # Description: # # Edit History: # 2011-02-24 File created. #======================================================================== #Steps [1] thru [6] consti...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: get4thLine.sh # Description: # # Edit History: # 2011-02-24 File created. #======================================================================== #When sed reads Line 1 (2, 3), since...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: get3rdTo6thLine.sh # Description: # # Edit History: # 2011-02-24 File created. #======================================================================== #Any line numbered greater than...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: syntax.sh # Description: # # Action Description # p Prints the line # d Deletes the line # s/pattern1/pattern2/ Substitutes the first occurrence of pattern1 with pattern2. # # sed -e '...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: syntax.sh # Description: # # Action Description # p Prints the line # d Deletes the line # s/pattern1/pattern2/ Substitutes the first occurrence of pattern1 with pattern2. # # sed -e '...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: strTableExtract.sh # Description: # # Edit History: # 2011-01-24 File created. #======================================================================== awk ' /string_data_item:/ { ...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: strTableExtract.sh # Description: # # Edit History: # 2011-01-24 File created. #======================================================================== awk ' /string_data_item:/ { ...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: variable.sh # Description: # Built-in Variables: # FILENAME The name of the current input file. # You should not change the value of this variable. # NR The number of the current in...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: syntax.sh # Description: # http://www.math.utah.edu/docs/info/gawk_1.html # http://www.grymoire.com/Unix/Awk.html#uh-4 # syntax: # awk 'script' files # # files: a list of one or mor...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: comparision.sh # Description: # syntax: # expression { actions; } # (expr1) && (expr2) # (expr2) || (expr2) # Edit History: # 2010-12-23 File created. #==========================...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: ctrlflow.sh # Description: # 1. if statement # if (expression1) { # action1 # } else if (expression2) { # action2 # } else { # action3 # } # 2. while statement # while (expression...
Shell
#!/bin/bash #======================================================================== # Author: YSLin # Email: # File Name: variable.sh # Description: # Built-in Variables: # FILENAME The name of the current input file. # You should not change the value of this variable. # NR The number of the current in...
Shell