123.txt #將內容輸出到 123.txt 之中,會蓋掉原有內容,若沒有檔案則會新增一個。
echo "append to the end of the file" >> 123.txt #將輸出內容附加到 123.txt 之中,若沒有檔案則會新增
#pipe `|`
#將前項的輸出結果當作後項的參數輸入
cat hello | grep o > result
which  按  按  編輯模式下輸入  編輯模式下輸入 pwd              #Print Working Directory 印出當前路徑
ls               #LiSt 印出路徑下的檔案
cd <path>        #Change Directory 切換路徑到path資料夾
cd ..            #回到上一層
cd ~ <Downloads> # ~ 代表 Users/user/
clear            #把畫面清空
touch <file>     #建立檔案或更改時間
rm <file>        #ReMove file 刪除資料夾可用 rmdir dir 或是 rm -r dir
mkdir <dirname>  #MaKe DIRectory
mv <file> <file_or_directory> #MoVe 移動檔案或者改名
cp <source> <goal>    #CoPy 複製檔案
cp -r <source> <goal> #複製資料夾
vim <file>          #用vim文字編輯器打開檔案
cat <file1> <file2> #接連印出兩個檔案的內容,也可只輸入一個檔案當作印出內容
less <file>         #分頁式印出檔案,按 q 離開
grep <string> <file> #搜尋字元
wget <url>           #由網址下載檔案
open <file>          #打開檔案
curl <url>           #送出 request。-I:只拿 header
#redirection `>`
echo "123" > 123.txt #將內容輸出到 123.txt 之中,會蓋掉原有內容,若沒有檔案則會新增一個。
echo "append to the end of the file" >> 123.txt #將輸出內容附加到 123.txt 之中,若沒有檔案則會新增
#pipe `|`
#將前項的輸出結果當作後項的參數輸入
cat hello | grep o > result
which <command>     #印出此指令的執行檔位置
ping <ip>           #持續丟封包過去伺服器,紀錄來回所花的時間
nslookup google.com #查詢 google 的 ip 位置
telnet 52.74.223.119 80 #去 ping 指定的 port 看有沒有開
#查詢功能與說明
man <command>
info <command>
<command> --help #windows 用這個或 /?
top  #table of processes
date #print current date
Vim
i 進入編輯模式,可以打字。Esc 進入普通模式。:q 即可退出編輯器(建立檔案後第一次進入要使用 q! 退出)。:wq 儲存後離開編輯器。String Handling
#搜尋字串,搜到則印出一整行 -E 則使用 RegExp
grep "match_pattern" file_name
#在一整行中印出特定欄位
# -F '"' 可把分隔符改成"
awk {‘print $欄位 $欄位 $欄位 ….’}
#剪出特定的片段
# <https://en.wikipedia.org/wiki/Cut_(Unix)>
cut [-b list] [-c list] [-f list] [-n] [-d delim] [-s] [file]
#把 pen 取代成 pencil
sed -e 's/pen/pencil/'