Time of Update: 2015-04-20
標籤:shell 一句話 bash 特定長字串 取出一系列字串中特定長的字串方法一#!/bin/bashhello="hello,world.my name is Jerry,what‘s your name ?"for word in ${hello[@]};do&nbs
Time of Update: 2015-04-18
標籤:ls 是查看目錄及目錄裡的檔案的命令接下來我們看這個命令的用法lsls 的文法主要有ls 查看目錄內容ls -l 查看檔案夾詳細資料ls -a 查看隱藏檔案ls -A 查看隱藏檔案,但不顯示"."和".."目錄資訊ls -d 將目錄象檔案相同顯現,而不是顯現其下的檔案ls -h 顯示檔案大小單位(通常和其他參數一起用)ls -R 遞迴顯示目錄和子目錄的內容ls -S 檔案從大到小排列也可以和其他參數一起使用ls -t
Time of Update: 2015-04-18
標籤:linux系統-shell編程-基本調試執行一 shell結構1 #!執行指令碼的shell2 # 注釋行 shell指令碼的注釋很重要,不可缺少3 命令和控制結構二 建立shell程式的步驟1 建立一個包含命令和控制結構的檔案2 修改檔案的許可權chmod u+x 對於普通使用者用 sh 指令碼 執行 對指令碼有r許可權, 對指令碼的目錄有rx許可權對於普通使用者用 指令碼 執行對指令碼和指令碼的目錄都有rx許可權3 執行:./example or sh
Time of Update: 2015-04-16
標籤:特殊變數列表變數含義$0當前指令碼的檔案名稱$n傳遞給指令碼或函數的參數。n 是一個數字,表示第幾個參數。例如,第一個參數是$1,第二個參數是$2。$#傳遞給指令碼或函數的參數個數。$*傳遞給指令碼或函數的所有參數。[email protected]傳遞給指令碼或函數的所有參數。被雙引號(" ")包含時,與 $* 稍有不同,下面將會講到。$?上個命令的退出狀態,或函數的傳回值。$$當前Shell進程ID。對於 Shell
Time of Update: 2015-04-16
標籤:路由器 shell mips 應用程式 如何將shell命令的返回值賦值給應用程式的變數。博主最近做了個路由器的項目,需要得到路由器現在網路狀態和參數,使用UCI get 獲得,但是使用了system(“UCI get
Time of Update: 2015-04-18
標籤:shell practice 1 1.require A B C D 1 2 3 4 5 6 7 8 3 5 8 0 1 2 4 3 after handling: T A B C D A 1 2 3 4 B 5 6 7 8 C 3 5 8 0 D 1 2 4 3 1.first need read the first line as an array. then append the element
Time of Update: 2015-04-16
標籤:1. 標準輸入,標準輸出與標準錯誤輸出Linux下系統開啟3個檔案,標準輸入,標準輸出,標準錯誤輸出。標準輸入:從鍵盤輸入資料,即從鍵盤讀入資料。標準輸出:把資料輸出到終端上。標準錯誤輸出:把標準錯誤輸出到終端上。預設的標準輸入指的是鍵盤,預設的標準輸出與標準錯誤輸出指的是螢幕或者是終端。系統為這三個檔案分配了檔案標識符fd(file descripter).在Linux系統下,一切皆是檔案,對檔案的操作,一般要用到檔案標識符。它們的檔案標識符,分別為0,1,2. 2.
Time of Update: 2015-04-16
標籤:目前的目錄下:find ./ -size +2048k |xargs du -b|awk ‘{print $1/1024/1024 "M" $2}‘|sort -n。。。。。。2.53318M./images3545s_.jpg2.53318M./images607s_.jpg2.53318M./image26s_.jpg2.53318M./image2153654s_.jpg2.63534M./images58s_.JPG 。。。。。。。。切忌的用法:find ./
Time of Update: 2015-04-19
標籤:linux shell 程式設計語言 linux系統-shell編程-幾個shell指令碼一 滅掉使用者 killuser.sh#!/bin/sh# The script to kill login useruser_name="$1"/bin/ps aux | /bin/grep $user_name | /bin/awk `{ print $2 }`
Time of Update: 2015-04-19
標籤:jos operating system shell Implement a Shell by yourself -- MIT xv6 shell這個其實是作為6.828的一個小課堂作業
Time of Update: 2015-04-13
標籤:shell 變數測試 變數替換 參考資料《鳥哥的私房菜——Linux基礎學習篇(第三版)》。在《鳥哥的私房菜——Linux基礎學習篇(第三版)》第11章中,鳥哥關於變數的測試與內容替換中,鳥哥最後用範例說明了變數替換中‘-‘、‘=‘、‘?‘三種特殊符號的用法。看完這些常式,給我最大的感受就是var=${str-newvar}或者var=${str=newvar}或者var=${str?ne
Time of Update: 2015-04-15
標籤:linux shell基礎 1. shell 特性:使用 history 命令查看命令曆史:[[email protected] ~]# history使用者的 history 記錄位於使用者家目錄下 .bash_history 檔案中:[[email protected] ~]# vim ~/.bash_history有關 history 的相關快捷操作:[[email protected]
Time of Update: 2015-04-12
標籤:linux shell應用技巧<span style="font-size:14px;">--------------------------------------shell應用技巧------------------------------------------一命令補全:tab鍵補全shell命令二:clear 或 ctrl+l 清屏ctrl+u 清除游標前面所有的內容 history 列出你敲過的所有命令命名別名定義:alias
Time of Update: 2015-04-12
標籤:假設我們定義了一個變數為: file=/dir1/dir2/dir3/my.file.txt 我們可以用 ${ } 分別替換獲得不同的值: ${file#*/}:拿掉第一條 / 及其左邊的字串:dir1/dir2/dir3/my.file.txt ${file##*/}:拿掉最後一條 / 及其左邊的字串:my.file.txt ${file#*.}:拿掉第一個 . 及其左邊的字串:file.txt ${file##*.}:拿掉最後一個 . 及其左邊的字串:txt
Time of Update: 2015-04-13
標籤: linux的檔案系統,是把硬碟空間格式化為若干node和block資料區塊,一般檔案的建立,目錄的建立,都會佔用一個node,如果建立的是檔案,具體的資料儲存在若干block資料區塊中,node記錄資料區塊的號碼,所有的node和block在檔案系統中都已經編號好;如果建立的是目錄,會佔用一個node,一個block,block中記錄著該目錄中所有的檔案名稱,block號碼記錄在node中。 根據linux檔案系統的大體結構,用檔案的方式,採用C++語言來類比一些在shell中執行的
Time of Update: 2015-04-20
標籤:http://www.cnblogs.com/chengmo/archive/2010/09/30/1839632.html #!/bin/bash# 指令碼檢測到離線主機會發送郵件通知,可一直運行。# 請根據你的需要設定 Mail gatewany ip lastip 四項 其餘不用設定Mail[email protected]163.com #警示郵件接收地址gateway=192.168.1.253 #內網網關ip
Time of Update: 2015-04-20
標籤:1 .插入排序的過程如同我們平時打撲克牌取牌插入的過程,不斷將取出的撲克牌插入已經排好的地方。插入排序過程初始有序區間大小為1,取出無序區間的首元素,尋找有序區間的合適位置,進行插入。不斷重複上述過程,即可完成操作。圖解樣本 1 //插入排序 2 //karllen @2015 3 void insertSort() 4 { 5 int i ,j ,temp; 6 for(i = 1;i<n;++i) //從第二個元素開始插入 7 { 8
Time of Update: 2015-04-22
shell指令碼編程(合并排序)#!/bin/bash#shell指令碼排序之合并排序a=(1 3 5 7 9)b=(2 4 6 8 10 12 14)c=n=5m=7i=0j=0k=0while [ $i -lt $n -a $j -lt $m ];doif test ${a[$i]} -gt ${b[$j]};thenc[$k]=${b[$j]}j=$(($j+1))k=$(($k+1))elsec[$k]=${a[$i]}i=$(($i+1))k=$(($k+1))fidone#echo
Time of Update: 2015-04-21
shell指令碼排序(冒泡排序),shell指令碼排序冒泡#/bin/basha=(9 84 51 0 345 1 2 34 1 0) #自己定義一個數組temp=for((i=0;i<10;i++)){for((j=i;j<10;j++)){ x=${a[$i]}if test $x -ge ${a[$j]}then temp=${a[$i]}a[$i]=${a[$j]}a[$j]=$tempfi}}for((k=0;k<10;k++)){echo -n ${a[$k]}
Time of Update: 2015-04-16
linux命令(while,shell參數的用法),linuxshell#!/bin/bash while IFS=: read name1 name2 name3 name4 #IFS是從檔案讀取內容時指定的分割符號,將a中的內容以:分開的部分分別賦值給相應變數. do echo $name1 '|' $name2 '|' $name3 '|' $name4 done <a