Open file without specifying exact location
Say I have a file in some obscure directory that I want to open and edit. I don't want to do something like this...
Code:
vim ~/foo/bar/blah/doh/ugh.txt |
if the file is unique locate should work just fine.
Code:
vim $(locate unique_name) your locate will also find. Make sure you specify a proper filter for the locate search, e.g., Code:
vim $(locate -r 'unique_name$') Cheers, Tink |
There isn't a good way. What if there are multiple files with that name? That being said if you don't mind only getting the first one you could do something like...
Code:
'vim $(locate filename.txt | head -1) Code:
alias vi-ugh='vim ~/foo/bar/blah/doh/ugh.txt' |
Thanks.
|
Please note the locate requires updatedb to keep track of files. locate will not find files created till updatedb has been run.
updatedb is often run from a cron at midnight or so |
Also, if you are worried about possible multiple return, you can issue the '-o' option and it will open all found.
Of course if the number is large it may look a little silly as you may only have one or so lines of each file. Please mark as SOLVED once you have a solution |
I suppose you could do something like make an alias to a for loop... for a single return it would edit first instance, then next, etc... but that would suck if you were a bit ambiguous.
|
All times are GMT -5. The time now is 02:41 AM. |