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

$ locate 

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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.