27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Appendix F. History Commands<br />

The Bash shell provides command−line tools for editing and manipulating a user's command history. This is<br />

primarily a convenience, a means of saving keystrokes.<br />

Bash history commands:<br />

1. history<br />

2. fc<br />

bash$ history<br />

1 mount /mnt/cdrom<br />

2 cd /mnt/cdrom<br />

3 ls<br />

...<br />

Internal variables associated with Bash history commands:<br />

1. $HISTCMD<br />

2. $HISTCONTROL<br />

3. $HISTIGNORE<br />

4. $HISTFILE<br />

5. $HISTFILESIZE<br />

6. $HISTSIZE<br />

7. !!<br />

8. !$<br />

9. !#<br />

10. !N<br />

11. !−N<br />

12. !STRING<br />

13. !?STRING?<br />

14. ^STRING^string^<br />

Unfortunately, the Bash history tools find no use in scripting.<br />

#!/bin/bash<br />

# history.sh<br />

# Attempt to use 'history' command in a script.<br />

history<br />

# Script produces no output.<br />

# History commands do not work within a script.<br />

bash$ ./history.sh<br />

(no output)<br />

Appendix F. History Commands 417

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!