# One-liner Commands 1\. 建立多個目錄 ```shell mkdir -p -v /home/josevnz/tmp/{dir1,anotherdir,similardir} ``` 2\. 搜尋取代關鍵字 ```shell # With sed

sed -i 's#ORIGINAL_VALLUE#NEW_VALUE#g' myfile1 myfile2



# With perl

perl -p -i -e 's#ORIGINAL#NEW_VALUE#' myfile1 myfile2 ``` 3\. 臨時以網頁方式分享特定目錄 ```shell # Python is required

cd $mydir && python3 -m http.server 8888 ``` 4\. 臨時寫一個多行的檔案 ```shell cat</my/new/file

Line1

Line2

A $VARIABLE

DOC ``` 或 Ctrl + D 結束離開 ```shell cat > testfile

This is a test

multiple lines

and here we go ``` 5\. 在指定目錄裡搜尋包含特定關鍵字的檔案 ```shell # With grep

grep -R 'import' --include='*.java' --color MySourceCodeDir



# With find

find MySourceCodeDir/ -name '*.java' -type f -print| xargs \

grep --color 'import ``` 6\. 用 watch 監控記憶體使用 ```shell watch -n 5 -d '/bin/free -m' ``` 7\. 更新所有的 Git 套件庫 ```shell for i in */.git; do cd $(dirname $i); git pull; cd ..; done ```