天天看點

linux 指令執行記錄,linux – 從曆史記錄執行一系列指令

如果您使用的是bash(或ksh),則内置的

fc允許您以各種方式操作曆史記錄.

fc -l # list recent history.

fc -l 2006 2013 # list commands 2006..2013

fc 2006 2013 # launch editor with commands 2006..2013; executes what you save

fc -e pico 2006 2013 # launches the editor pico on command 2006..2013

fc -e - 2006 2013 # Suppresses the 'edit' phase (but only executes the first listed command)

fc -e : 2006 2013 # Launches the ':' command (a shell built-in) as the editor

ksh中的經典技術是使用别名别名r =’fc -e – ‘,但由于bash的行為,有必要稍微扭曲它的手臂并使用别名r =’fc -e:’代替.