0

I'd like to get the nth (3rd) result of locate, and then open it to vi.

$ locate 
/private/etc/my.cnf
/private/etc/my.cnf.bak_
/usr/local/mysql-5.6.22-osx10.8-x86_64/my.cnf 
....
srph
  • 113

1 Answers1

2

You need a pattern for locate; say "my.cnf":

vi $( locate my.cnf | head -n3 | tail -n1 )

Caveat: No newlines in the filenames, please. :)