One-liner Commands 1. 建立多個目錄 mkdir -p -v /home/josevnz/tmp/{dir1,anotherdir,similardir} 2. 搜尋取代關鍵字 # With sedsed -i 's#ORIGINAL_VALLUE#NEW_VALUE#g' myfile1 myfile2# With perlperl -p -i -e 's#ORIGINAL#NEW_VALUE#' myfile1 myfile2 3. 臨時以網頁方式分享特定目錄 # Python is requiredcd $mydir && python3 -m http.server 8888 4. 臨時寫一個多行的檔案 cat</my/new/fileLine1Line2A $VARIABLEDOC 或 Ctrl + D 結束離開 cat > testfileThis is a testmultiple linesand here we go 5. 在指定目錄裡搜尋包含特定關鍵字的檔案 # With grepgrep -R 'import' --include='*.java' --color MySourceCodeDir# With findfind MySourceCodeDir/ -name '*.java' -type f -print| xargs \grep --color 'import 6. 用 watch 監控記憶體使用 watch -n 5 -d '/bin/free -m' 7. 更新所有的 Git 套件庫 for i in */.git; do cd $(dirname $i); git pull; cd ..; done