Time of Update: 2015-05-21
標籤:Database Backup database shell backup 由於個人建站不能保證比較高的可用性,可能存在資料容易的問題,所以就要實現備份資料庫的需求,於是本人在網上找了一些資料,結合本人實際情況,通過使用指令碼實現每天淩晨12點備份資料庫,每周日定時刪除七天以前的Database
Time of Update: 2015-05-23
標籤:1、注釋 如果使用bash,則在指令檔頭注釋:#/bin/bash2、將指令檔加上可讀與執行許可權,就可以使用./shell.sh來執行,也可以使用sh shell.sh的方式來直接執行,sh是bash的軟串連3、test判斷語句用法 test -d Desktop && echo "is a dir" || echo "is not a dir" 尋找管道檔案:ll /dev | grep ‘^p‘,在dev目錄下,以p開頭的是管道檔案
Time of Update: 2015-05-22
標籤:opkg updateopkg install ddns-scripts luci-app-ddns用上面的命令下載ddns指令碼,編輯設定檔vi /etc/config/ddns配置如下config service "myddns" option enabled "1"
Time of Update: 2015-05-19
標籤:$0:當前指令碼的檔案名稱$num:num為從1開始的數字,$1是第一個參數,$2是第二個參數,${10}是第十個參數$#:傳入指令碼的參數的個數$*:所有的位置參數(作為單個字串)[email protected]:所有的位置參數(每個都作為獨立的字串)。$?:當前shell進程中,上一個命令的傳回值,如果上一個命令成功執行則$?的值為0,否則為其他非零值,常用做if語句條件$$:當前shell進程的pid$!:後台啟動並執行最後一個進程的pid$-:顯示shell使用的當前選
Time of Update: 2015-05-22
標籤:shell while 乘法表同其他語言一樣,迴圈同樣是shell中的指令碼句型 一。文法: while [ 運算式 ]
Time of Update: 2015-05-15
標籤:linux[Author]: kwu 在linux中日期格式化固定為8位:2015-01-01如實現 2015-1-1 需要進行字串處理#!/bin/sh# upload logs to hdfsyesterday2="2015-01-08"echo ${yesterday2}first=${yesterday2:5:1}second=${yesterday2:8:1}echo ${first}echo
Time of Update: 2015-05-17
標籤:簡單說一下popen()函數函數定義#include <stdio.h>FILE * popen(const char *command , const char *type );int pclose(FILE
Time of Update: 2015-05-11
標籤:shell實戰1: 輸入2個整數,判斷大小三種方式實現:1 定義變數 2 指令碼傳參 3
Time of Update: 2015-05-08
標籤:shell內建命令
Time of Update: 2015-05-08
標籤:[[email protected] shell]# cat mod_ip_hostname.sh #!/bin/bash#Auto modify ip and hostname#by colin on 2015-05-07IP_CONFIG=‘/etc/sysconfig/network-scripts/ifcfg-eth0‘HOSTNAME_CONFIG=‘/etc/
Time of Update: 2015-05-05
標籤:shell指令碼變數和字串截取 字串修剪變數說明:$$ Shell本身的PID(ProcessID)$! Shell最後啟動並執行後台Process的PID$? 最後啟動並執行命令的結束代碼(傳回值)$- 使用Set命令設定的Flag一覽$* 所有參數列表。如”$*”用「”」括起來的情況、以”$1 $2 … $n”的形式輸出所有參數。[email protected] 所有參數列表。如”[email protected]”用「”」括起來的情況、以”$1″ “$2″ …
Time of Update: 2015-04-30
標籤:shell-內建命令注釋: # 注意:shell 檔案開頭的#!/bin/bash 裡的#不是注釋運行: 1、bash shell.sh 2、chmod +x shell.sh -> ./shell.sh 3、添加到PATH 變數中 4、. ./shell.sh排錯: 1、語法錯誤 運行時會有提示 2、邏輯錯誤 使用echo 列印, sleep number:睡眠number 秒,降低迴圈速度
Time of Update: 2015-04-30
標籤:shell 整數運算 運算子 算數運算子 shell只支援整數運算 常見的算數運算大多結合shell的內建命令let來使用。 + - * / % **(冪運算) += -= *= /= %= 位元運算 >> << & | ^ ~ 自增自減 ++ --
Time of Update: 2015-04-28
標籤:linux shell 指令碼 使用者輸入 1.運行帶參數的程式$0表示程式名,$1表示第一個參數,$2表示第二個參數,一次類推,直到第九個參數$9# vi factorial#!/bin/shf=1for((i=1;i<=$1;i++))do f=$[ $f * $i]doneecho
Time of Update: 2015-04-22
標籤:·CMD·在執行的時候,shell不管··中的內容是什麼,先進性解釋,再把解釋後的最終結果送給shell,如果解釋後的結果不是shell可以行的命令,就會報錯。但是僅僅把cmd的執行結果作為文本輸出,就沒有問題。如:[[email protected] root]# i=0[[email protected] root]# name=pwd[[email protected] root]#
Time of Update: 2015-04-22
標籤:shellshell函數的返回值(return),僅支援整數#!/bin/shget_str(){return "string"}get_strecho $?輸出如下:./test.sh: line 5: return: string: numeric argument required255可以看到已經提示要求return 整數類型,真實返回值是255。解決辦法:#!/bin/shget_str(){echo
Time of Update: 2015-04-23
標籤:hbase shell操作大全 hbase shell操作 1.進入Hbase命令列>hbase shell退出命令列>quit2.建立表>create 'users','user_id','address','info'3.查看所有表>list4.查看錶結構>describe
Time of Update: 2015-04-22
標籤:shell編程---條件判斷一.shell編程之條件判斷 1.整數測試 a.條件測試的運算式 [ expression ] [[ expression ]] test expression b.整數比較 -eq: 測試兩個整數是否相等;比如 $A -eq $B -ne: 測試兩個整數是否不等;不等,
Time of Update: 2015-05-11
標籤:希爾排序法(縮小增量法)
Time of Update: 2015-04-20
標籤:#!/bin/bash#shell指令碼編程之快速排序的實現(以最右邊為元點的思想)a=(8 5 10 3 2 93 4 1 2 3 40 9 61 8 6 29)temp=buff=#交換函數swap(){buff=${a[$1]}a[$1]=${a[$2]}a[$2]=$buff}fun(){i=$(($1-1))j=$1temp=${a[$2]}if test $1 -ge $2 ;thenreturn 2 fiwhile [ $j -le $2 ];dowhile [ $j