1. Shortcut
Ctrl-a
Move to the begining of the lineCtrl-e
Move to the end of the lineCtrl-u
Deletes from cursor to beginning of lineCtrl-k
Deletes from cursor to end of lineCtrl-w
Deletes from cursor one word beforeCtrl-l
same as clear command
2. SystemInformation
free
:memory informationcat /proc/cpuinfo
:CPUdf
:harddiskdu
:folder
※ -h
を付けてHelp情報を調べる
3. ファイルを一括作成
touch {apple,orange,banana}
touch file_{001..100}
echo {a..Z}
touch {apple,banana,cherry}_{01..100}{w..d}
ls -l | wc -l
:计算行数,即得到当前文件夹内文件数目
4. pipe
cp -v * ../otherfolder 1>../success.txt 2>../error.txt
:普通的出力输出到sucess.txt,error输出到error.txtcp -v * ../otherfolder &>../log.txt
:普通的出力和error都输出到log.txtls > /dev/null
:不输出,丢到类似回收站的地方echo "Some text" > file.txt
:写入文件echo "Some more text" >> file.txt
:追加模式写入文件> file.txt
:覆盖模式,清空文件
5. grep
grep error auth.log
grep --color=auto error auth.log
export GREP_OPTIONS='--color=auto'
grep -i break-in auth.log
grep -i break-in auth.log | awk {'print $12'}
ping -c 1 example.com | grep 'bytes from' | cut -d = -f 4
6. 环境变量
$HOME
$PWD
$MACHTYPE
$HOSTNAME
$BASH_VERSION