2007-01-10

etbe: some random Linux tips

Posted in Computers, PlanetDebian at 20:20 CET (+0100) by sven

Russel Coker wrote in etbe: some random Linux tips:

Prefixing a bash command with ‘ ‘ will prevent a ! operator from running it. For example if you had just entered the command ” ls -al /” then “!l” would not repeat it but would instead match the preceeding command that started with a ‘l’. On SLES-10 a preceeding space also makes the command not appear in the history while on Debian/etch it does (both run Bash 3.1).

It’s pretty easy to get the Bash shell to ignore lines starting with a space in its history: Just add

export HISTCONTROL=ignorespace

to your ~/.bashrc. Alternatively, ignoredups ignores duplicates and ignoreboth ignores both.

It’s also possible to tell Bash to ignore lines which match a specific pattern. For example,

export HISTIGNORE=" *:~/*"

will ignore any command starting with a space (emulation the ignorespace option to HISTCONTROL) or starting with ~/ (any program/script in or below your directory).

Personally, I just use “HISTCONTROL=ignoreboth“.

Leave a Comment