Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Operating System - Tru64 Unix
cancel
Showing results for 
Search instead for 
Did you mean: 

How to open a file in a different directory using vi

Sirisha_1
Occasional Visitor

How to open a file in a different directory using vi

I would like to know if there is any way to open a file that is in some different directory , without giving the absolute path name . I mean , just by giving the name of the file to vi .Is there any way to achieve this by manipulating the path variable or using vi with any option .
2 REPLIES
Mark Grant
Honored Contributor

Re: How to open a file in a different directory using vi

No, there isn't but there are ways you could make it look like that.

symbolic or hard link from the file to your current directory is one way.

alias "vmyfile=vi /long/path/to/myfile" so that when you type vmyfile it edits it.

MYFILE=/really/long/path/top/myfile
vi $MYFILE

Maybe this will help.
Never preceed any demonstration with anything more predictive than "watch this"
Romildo
Occasional Visitor

Re: How to open a file in a different directory using vi

Try to use a script that do the following ...

#!/usr/bin/ksh
file=$(which $1)
vi $file

the script would be call vi.sh and you use vi.sh file.

good luck.

Romildo