One thing that I frequently do is edit the most recently modified files, so instead of typing "ls -lr" and then "vim lastfile", I thought I would make some shortcuts in my ~/.bash_profile file:
alias via="vim `ls -rt | tail -1`"
alias vib="vim `ls -rt | tail -2 | head -1`"
alias vic="vim `ls -rt | tail -3 | head -1`"
alias vid="vim `ls -rt | tail -4 | head -1`"
alias vie="vim `ls -rt | tail -5 | head -1`"
The problem is that, weirdly enough, these commands don't work. They open some file that isn't one of the last, or even a file was deleted from the current directory (I wonder if there's some kind of file cache updating issue in the directory. This occurs on both my local machine and the cluster I work on).
However, if I type vim `ls -rt | tail -1`
directly, without using the alias, it works every time.
ls
output here..bashrc
, not.{,bash_}profile
.