The Archives

  • 13.Jan.16
    Add timestaps to your bash history shell | fernape | (0)
    bash history is very useful to access your past commands. Sometimes it would be just great to know when a command was typed to be able to correlate it to another event. Imagine we know that there was a change in a repository that might have fixed a heisenbug. But we know that not long ago, we saw the bug again. But are we sure it was before the change in the repository was made? We can solve this (and other problems) by adding time stamps to our bash history. Add the following line to your .bash_profile file: export HISTTIMEFORMAT="%d/%m/%y %T " The ...
  • 15.Jun.08
    More on bash history shell | fernape | (2)
    Bash provides a powerful history system that helps you in repeating commands and arguments. For example, the !! command, repeats the last executed command. If you want to execute a command typed before the last one, you can select it with the following: !-number Something like this: $ ls $ ps $ !-2 The last command executes ls again. In addition, you can specify previous arguments too. This is done with the !:n command (n being a number). Let's see an example: $ less file.txt $ cp !:1 file_copy.txt The last command takes the first argument of the previous executed command and makes a copy with a different name. If this is not ...
  • 24.May.08
    Search backwards in history cmd | pfortuny | (0)
    (This is not a command 'stricto sensu' but a must-know). Assume you are in the shell, after some work. If you press CTRL-r, you enter the incremental history search mode: you just type something you remember you typed and the last executed command containing it appears. Then you either press ENTER to execute the line or the right arrow to edit it or CTRL-r again to continue the search. Try it and enjoy.