[Nottingham] 10 shortcuts to master bash, backgrounding, and screen

David Aldred david at familyaldred.org.uk
Wed Sep 16 16:48:55 UTC 2009


On Wednesday 16 September 2009, Iain Lane wrote:
> The various history navigation commands, documented at [0] are  
> indispensable for me - they make my shell life so much more efficient.  
> The article doesn't mention that you can repeat sequences of commands  
> by finding one (for example with C-r) and hitting C-o instead of enter  
> to execute. After this finished, your prompt will be pre-filled with  
> the next command in the history. Magic or wot?
> 
Even more magic in the history context is the fc command:  I'm sure people 
here know it far better than I do, but

	fc -l 15

lists the last 15 commands, numbered (I think 15's the default anyway, but you 
can specify any number you like).  You can then use those numbers in two ways:

	fc -s 456

will repeat the  command numbered 456;  and 

	fc 456 461

will put the commands numbered 456 to 461 into your default editor.  Edit them 
as you will; exiting the editor will lead to the edited commands being 
executed.   

Alternatively, save them, and (subject to adding a #! line and suitable 
comments) you have a script ready-made - but in that case do remember that 
closing your editor will still execute the lines!

-- 
David Aldred



More information about the Nottingham mailing list