Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] useful bash tricks thread


On Fri, Feb 06, 2009 at 09:06:25PM +1100, Tony Sceats wrote:
> It's been a while since there's been a thread like this, so I thought it
> would be fun :)
> 
> so, have you got any?

I'm fond of the -t flag to ls, which orders by mtime desc. I have
these defined in my .bashrc:

  lead() {
    ls -lt $* | head -20
  }

which is combination ls+head, giving you back the 20 most recently 
modified items in your current (or given) directory; and:

  alias l1='ls -t | head -1'

which gives you back the filename of the most recently modified 
object. I use this all the time with `` e.g.

  # Create an invoice
  invoice companyX
  # Check it (the newest file) in evince
  evince `l1`


Cheers,
Gavin