2014年11月28日 星期五
bash 取得 linux 核心版本
:;function fun_uname { :;local v;read v </proc/version;v=${v#*version };v=${v%% *};echo $v; return 0;};
bash read 游標範例
while true ;do
read -n3 a
[ "$a" = $'\x1b[B' ]&&echo = down =
[ "$a" = $'\e[A' ]&&echo = up =
done
read -n3 a
[ "$a" = $'\x1b[B' ]&&echo = down =
[ "$a" = $'\e[A' ]&&echo = up =
done
Bash 取得指令真正路徑
:;function fun_getcmdpath { :;local _t=$(type -P $1 2>/dev/null); [ $? -eq 0 ] && echo $_t;};
Bash script 複製來源檔案的目錄結構
:;function fun_pathcp { :;_d=${1%*/*};[ $1 = $_d ] && _d=".";mkdir -p /$2/$_d;cp -fcp $1 /$2/$_d/;};
BASH 4 讀取 HTTP 資料
exec 6<>/dev/tcp/www.google.com/80
echo "GET / HTTP/1.1
host:www.google.com
" >&6
TIMEOUT=3;
while read -t $TIMEOUT <&6;do echo $REPLY && TIMEOUT=0.05; done
exec 6<&- && exec 6>&-;
echo "GET / HTTP/1.1
host:www.google.com
" >&6
TIMEOUT=3;
while read -t $TIMEOUT <&6;do echo $REPLY && TIMEOUT=0.05; done
exec 6<&- && exec 6>&-;
2014年11月20日 星期四
訂閱:
文章 (Atom)