A Bunch of Bash tips. ^*^*^**^*^*^*^*^*^**^ This is a little article about bash. If you are using a bash you'll be glad to know that things ( if you already don't ), and use it regularly every day. 1. Pressing ctrl+r would show you incremenatal reverse search just type some words from your previous commands and you get the whole command line immediately. The search is being done incremental line by line from the history buffer in backwards over the whole history. 2. $_ in bash is the default variable it stores the previous command parameters. Example: ls -al; echo $_; And you'll see $_ is equal to "-al". Another example in the same context would be: $ cat /etc/passwd /etc/hosts Stuff goes here ... $ !cat !cat would be the same as cat $_ and $_ would hold the cat command parameters, so the above command would be executed the same again. 3. If you just need to see what's in the current directory type ls and press "TAB" twice. That would list you the directory structure using the auto completion bash feature. 4. ctrl+q - That key combination locks your screen until ctrl+s is typed. Example: if you have urgent job and you need to lock your terminal because your kid may do something ugly to your machine just type ctrl+s and have fun, then come back and press ctrl+q ;]. 5. If you were in some directory and then switched to another and want to come back to where you previously were execute "cd -" Example: cd /tmp; cd /var/tmp; now you have to operate with /tmp again. cd -; Yep you are in /var/tmp again. For more check out help popd and help pushd. 6. setting HISTFILESIZE=0 tells bash your bash history buffer to be cleared during logout and no data is being written to .bash_history. 7. setting HISTCONTROL=ignorespace. makes bash not to log to .bash_history commands starting with empty space. $ls -> that would be logged. $ ls -> that won't because it starts with empty space ;] 8. Using ls *.{exe,com,conf} is another funky feature. The above line would list you all files ending with *.exe *.com and *.conf. 9. Listing all directories can be acomplished like that. Example: ls -l */ 10. env = will print you your environment variables and values. 11. export HISTFILE=/dev/null or unset HISTFILE; would make your commands from the current session not to be logged to .bash_history. 12. If you need a bunch of commands to be executed during your logout just put them in .bash_logout 13. The "source command" If you have modded your .bashrc or .bash_profile and need to reread the changes without logout type source ~/.bash_profile or type . ~/.bash_profile that would include their content to your current environment. 14. Typing ctrl+u in bash would delete your whole line from your cursor to the beginning of the line. 15. Typing ctrl+w in bash would delete the current word you're on. 16. Pressing ctrl+l would clear the screen. If you have two words and want to change their order like the first to become last and the last to become first press ctrl+t. 17. Typing ctrl+d would execute logout on the remote node or the local shell. 18. echo *, could be used instead of ls. 04.05.2005