Time of Update: 2018-12-05
awk中使用shell變數疑問 作者:swysn 發表時間:2002/03/22 05:01pm[這個貼子最後由valentine在 2002/10/22 08:46am 編輯]2002/01/01 1312 32132 AA 32132131#!/bin/shecho "ENTER:"read keycat tt|awk '{if(prev=="$key")print;prev=$1} 以上內容如果我輸:2002/01/01沒結果輸出!又錯了?
Time of Update: 2018-12-05
一個shell指令碼解多個壓縮檔(改別人的代碼) 這個程式核心代碼是有linuxsir.org的tram兄寫的,主要是時限瞭解壓縮檔的功能.我加了一些代碼使他能夠壓縮目錄和解開rar檔案,這個SHELL程式還是很簡單的,我經常用他,將程式的許可權用chmod gou+x filename該為可執行,然後複製到/bin/usr下.這樣就可以使用了.呵呵. 一下就是代碼.#!/bin/bashif [ -d $1 ]; thentar
Time of Update: 2018-12-05
在linux下擷取時間字串命令 date# 以yyyymmdd格式輸出23天之前現在這個時刻的時間$ date +%Y%m%d --date='23 days ago'$ date -uThu Sep 28 09:32:04 UTC 2006$ date -RThu, 28 Sep 2006 17:32:28 +0800# 測試十億分之一秒$ date +'%Y%m%d %H:%M:%S.%N';date +'%Y%m%d %H:%M:%S.%N';date +'%Y%m%d %H:%M:%S.
Time of Update: 2018-12-05
UNIX Shell 編程(2) 字元匹配星號(*)匹配0個以上的字元;而問號(?)則匹配1個字元。如:ls [a-z]*[0-9]表示顯示檔案名稱以小寫字母開始,且以數字結尾的檔案清單。輸出重新導向命令的輸出一般是提交到標準輸出裝置,可以轉向到檔案內,這叫輸出重新導向。在有標準輸出的命令後,添加>file符號後,命令的輸出就會寫入檔案file。如:[root@localhost misc]# whoroot pts/1 2009-04-14 09:39 (10.3.
Time of Update: 2018-12-05
UNIX Shell 編程(5) 過濾器tr用來轉換來自標準輸入的字元。格式:tr from-chars to-charsfrom-chars 和 to-chars 是一個或多個字元。例如:[root@localhost programs]# cat introThe Unix operating system was pioneered by Ken Thompson and Dennis Ritchie at Bell Laboratories in the late 1960s. One
Time of Update: 2018-12-05
tr tracslate 的簡寫例1 替換字元,把小寫r替換成大寫的Rshuohailhl@shuohailhl-PC /cygdrive/d$ cat pass.txtroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinshuohailhl@shuohailhl-PC
Time of Update: 2018-12-05
shell中實現保證同一時間內只有一個進程在實現: 1.lockf命令 2.簡單實現:i=`ps -ef|grep [n]ew_mvbackup|wc -l`if [ $i -gt 1 ];thenecho "wait for the other mvbackup finish!"exit -1else#do something here 3.另外一種實現:lock_on(){ local f=$1 local freefd=6 ## do not use fd 5 ##
Time of Update: 2018-12-05
1、find命令選項f i n d命令有很多選項或運算式,每一個選項前面跟隨一個橫杠-。 -name 按照檔案名稱尋找檔案。 -perm 按照檔案許可權來尋找檔案。 -prune 使用這一選項可以使f i n d命令不在當前指定的目錄中尋找,如果同時使用了- d e p t h選項,那麼- p r u n e選項將被f i n d命令忽略。 -user 按照檔案屬主來尋找檔案。 -group 按照檔案所屬的組來尋找檔案。 -mtime -n +n
Time of Update: 2018-12-05
1. 寫一個指令碼,利用迴圈計算10的階乘#!/bin/shfactorial=1for a in `seq 1 10`dofactorial=`expr $factorial /* $a`doneecho "10! = $factorial" 2. 寫一個指令碼,執行後,列印一行提示“Please input a number:",要求使用者輸入數值,然後列印出該數值,然後再次要求使用者輸入數值。直到使用者輸入"end"停止。#!/bin/shunset varwhile [ "$var" !
Time of Update: 2018-12-05
有系統營運的過程中,記錄檔往往非常大,這樣就要求對記錄檔進行分割,在此特用shell指令碼對檔案進行分割 方法一: #!/bin/bash linenum=`wc -l httperr8007.log| awk '{print $1}'` n1=1 file=1 while [ $n1 -lt $linenum ] do n2=`expr $n1 + 99
Time of Update: 2018-12-05
有時候一個任務啟動並執行時間很長,需要將其放在後台運行,否則推出控制台後任務就會被終止,本文講解一下怎麼讓任務在後台運行。比如一個shell指令碼,longjobs.sh運行要很長時間,並且運行中有資訊列印到控制台。1,如果直接通過
Time of Update: 2018-12-05
1、重新導向1. 標準輸入(stdin) :代碼為 0 ,使用 < 或 << ;(重寫或追加)2. 標準輸出(stdout):代碼為 1 ,使用 > 或 >> ;3. 標準錯誤輸出(stderr):代碼為 2 ,使用 2> 或 2>> ;eg:yee@Loong:~$ ifconfig > 1.txtyee@Loong:~$ vim 1.txt yee@Loong:~$ ls -al 2.txt >>1.txtls:
Time of Update: 2018-12-05
Term : FreeXploiT Author : ALLyeSNODate : 2005-06-21Codz: @echo off :: Ncfoever 1.0 bulid by ALLyeSNO 2005-06-13 :: 可用於tcp連接埠資料包的捕獲 cls ::/* 參數判斷以及使用說明 */ set count=1 if /i "%1"=="-look" goto nclook if /i "%1"=="-log" goto nclog echo. echo =====
Time of Update: 2018-12-05
1 shell script必須具備可讀與可執行(rx)的許可權。 2 script的執行方式的區別: 1)sh script_name或./script_name:在子進程中執行(一個新的bash環境) 2)source script_name:在父進程中執行 【提示】當子進程完成後,子進程內的各項變數或者操作將會結束而不會傳回到父進程中 3 script的編程習慣
Time of Update: 2018-12-05
這裡我首先會介紹一個Shell是什麼,再介紹我的第一個Shell程式和從中總結的經驗。一、Shell是什麼在說我的這個Shell程式之前,還是先跟大家說說什麼是Shell吧,相信Shell這個詞大家一定聽過很多了,但是它其實是什麼東西呢?其實Shell是一個程式,我們在shell中輸入一些命令,它就告訴作業系統核心我們想做什麼,好讓核心可以控制硬體來正確無誤地工作。簡單點來說就是,Shell的功能只是提供一個使用者作業系統的介面,而這個shell則可以調用其他的程式來完成這些操作,只要能操作應用
Time of Update: 2018-12-05
hadoop shell命令遠程提交一,hadoop shell命令遠程提交原理 hadoop shell命令執行目前很多情境下面主要通過 Linux shell來互動操作,無論對於遠程操作還是習慣於windows/web操作的開發人員而言,也是非常痛苦的事情。 在hadoop安裝包中的src\test\org\apache\hadoop\cli\util 目錄中,CommandExecutor.java地實現方式或許對大家有一定啟發。 如下是一段hadoop
Time of Update: 2018-12-05
第四章 控制流程結構1,if語句if 條件1; then 命令1elif 條件2;then命令2else 命令3fiif 條件then 命令fi***************************************************************#!/bin/bashif [ "10" -lt "12" ]thenecho "Yes,10 is less than 12"else echo "No!!"fi*********************************
Time of Update: 2018-12-05
#!/bin/bashcat 1 | grep " 403 " | while read linedo index=`expr index "$line" GET` let startindex=$index+3 echo "startindex:"$startindex endindex=`expr index "$line" \?` echo "endindex:"$endindex if [ 0 -eq $
Time of Update: 2018-12-05
1 shell 的$! ,$?, $$,$@ •$n $1 the first parameter,$2 the second... •$# The number of command-line parameters. •$0 The name of current program. •$? Last command or function's return value. •$$ The program's PID. •$
Time of Update: 2018-12-05
Bourne Shell 介紹:Bourne Shell 基礎及其他很多有用的特性,shell編程及組織。 主要內容: .shell基礎 基本介紹,環境,選項,特殊字元 .shell變數 使用者定義變數,環境變數,位置變數(shell 參數) .shell script編程 條件測試,迴圈及重複控制 .shell定製 1.shell基礎知識 作者:Stephen Bourne 在Bell實驗室開發 建議:man sh 查看相關UNIX上的改進或特性 (1)shell提示符及其環境