Skip to main content
1 of 6
Santosh Kumar
  • 4.2k
  • 7
  • 30
  • 36

Trying to "locate" and then open a file

Suppose that I have a file named filename123.txt and it is the single file that is named so, and I can find/locate it with the command locate filename123. And it returns only this file.

Now I want to open it with vi/vim. But I don't want to go to that location and type the vi command followed by filename. Here I want the result of locate filename123 to be appended to the vi command. How can I do so? I already tried:

locate filename123 | vi

But this does not works. And this error comes in terminal:

santosh@santosh:~$ locate filename123 | vi
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...

Vim: Finished.




santosh@santosh:~$
Santosh Kumar
  • 4.2k
  • 7
  • 30
  • 36