mkdir
Date: 08-27 v1
建立新目錄
語法
mkdir [-p] <目錄名>
OPTION
無參數: 如果該目錄不存在,才建立它。若該目錄在則顯示目錄已存在錯誤訊息,並且回傳值為1-p: 如果該目錄不存在,才建立它。若該目錄在則略過,並且回傳值為 0
範例
# mkdir new_directory
#
# mkdir new_directory
mkdir: can't create directory 'new_directory': File exists
# echo $?
1
# mkdir -p new_directory
# mkdir -p new_directory
# echo $?
0
mktemp
Date: 05-14 v1
產生暫存檔案或目錄
語法
mktemp [OPTION] ... [TEMPLATE]
OPTION
-u: --dry-run 不產生任何檔案或目錄,只顯示名稱 (不安全, 僅供測試, 因為有可能重複產生)
範例
bash-5.0# mktemp -u /you_path/path2/your_prefix.XXXXXXXXXX
/you_path/path2/your_prefix.zjvveu0Ncs
# mktemp /tmp/your_prefix.XXXXXXXXXX
/tmp/your_prefix.5eEu7vU0zi
# ls -la /tmp/your_prefix.5eEu7vU0zi
-rw------- 1 test test 0 May 15 00:06 /tmp/your_prefix.5eEu7vU0zi
/you_path/path2/your_prefix.zjvveu0Ncs
# mktemp /tmp/your_prefix.XXXXXXXXXX
/tmp/your_prefix.5eEu7vU0zi
# ls -la /tmp/your_prefix.5eEu7vU0zi
-rw------- 1 test test 0 May 15 00:06 /tmp/your_prefix.5eEu7vU0zi
read
語法
read [argument1] [argument2] ...
範例
bash-5.0# find . -type f | while read filename ; do echo "$fiilename" ; done |
sed
刪除空白行
語法
sed -e "/^$/d"
範例
bash-5.0# echo -e "te\n\nst" | sed "/^$/d" te st |
type
語法
type command1 command2 ...
範例
bash-5.0# type type type is a shell builtin type a b a is a function a () { echo 'a' } b is a function b () { echo 'b' } |
xargs
語法
xargs [argument1] [argument2] ...
範例
bash-5.0# find . -type f | xargs wc -l | sed -e "s/^[ \t]*//g" 2 ./b.txt |
沒有留言:
張貼留言