顯示具有 file 標籤的文章。 顯示所有文章
顯示具有 file 標籤的文章。 顯示所有文章

2012年8月20日 星期一

create large file with dd command

要一個大的 file 作 loop back。
要先 create。

以往都是用: dd if=/dev/zero of=10G bs=1G count=10 這樣會花一些時間,硬碟把 00 寫入 10G 的 file。


要是不管file 的內容,只要10G 大小,可以用: dd if=/dev/zero of=10G bs=1 count=0 seek=10G 這樣馬上就可以create 出來。


  • http://www.skorks.com/2010/03/how-to-quickly-generate-a-large-file-on-the-command-line-with-linux/

2012年7月23日 星期一

copy files according the list file

其實這是 moore 的 script。
他把各系統要 copy 的 filename 寫在同一個 list file 中,每個 filename 用 ≶ > 刮起來。
仿造 xml 格式,裡面是 系統名稱。
<N_Series>MyBrowser.apk</N_Series>

所以要寫一個 script,依照這個 list 內容來 copy files..




要注意那個從 filelist xml 中剔除 tag 的 sed,要先把 </...> 剔除,再剔除開頭的。
否則因為整個 entry 剛好被包圍,所以會被整個剔除。

2011年7月21日 星期四

test condition : file, directory

用在 if, while 等 流程控制 的判斷,像
if [ -f /etc/passwd ]; then
echo "found"
else
echo "not found"
fi

其中的 -f 就代表 is a file.

https://sites.google.com/site/tiger2000/home 有列出所有的 file test 選項:
[ -e file ] file exists
[ -f file ] file is a file
[ -d file ] file is a directory
[ -c file ] file is a character device
[ -b file ] file is a block device
[ -p file ] file is a named pipe
[ -s file ] file is not empty
[ -k file ] file's sticky bit is set
[ -S file ] file is a socket
[ -L file ] file is a symbolic link
[ -r file ] file is readable by user
[ -w file ] file is writeable by user
[ -x file ] file is executeable by user
[ -O file ] file is owner by user
[ -G file ] file is group owned by a greoup
[ -u file ] file has its set user ID bit set
[ -g file ] file has its group user ID bit set
[ file1 -nt file2 ] file1 is newer than file2
[ file1 -ot file2 ] file1 is older than file2
[ file -ef file2 ] file1 is another name for file2

[ $str1 = $str2 ] str1 string is the same as string str2

另外一個,是 and , or 的 邏輯運算:

-a and
-o or
! not

* 奇怪的是 這些 邏輯運算後面的 operand 好像要加"" 括號