2009年7月8日

Linux Bash 小技巧

// 使用 Tab 自動補齊 command 或是 file path(name)

$ ca<Tab> /et<Tab>/pass<Tab>
$ cat /etc/passwd

// 使用 history 列出執行過的 command 和 !<num> 來再次執行 command

$ history | tail
208 ls -al
209 cat /etc/passwd
210 cat /etc/hosts
211 cat /etc/mime.types
212 cat /etc/networks
213 df
214 mount
215 env
216 uname -a
217 history | tail

// 再次執行第 211 command

$ !211 | more
cat /etc/mime.types | more
# $Id: mime.types,v 2.0 1998/12/12 08:06:44 roessler Rel $

#
# sample mime.types
#

application/andrew-inset ez
...

// 使用 Ctrl+R 來找執行過的 command ,按 Enter 後再次執行 command

$ <Ctrl+R>un
(reverse-i-search)`un': uname -a<Enter>
$ uname -a

沒有留言:

網誌存檔