Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ls | vi shell script

Status
Not open for further replies.

jriggs420

Programmer
Sep 30, 2005
116
US
I've come up with a simple shell script that works, but I want to refine it a bit so maybe some others can use it. Basically, it allows to me open a file from certain directory regardless of my cwd:
Code:
vi `ls /home/jriggs/dox/*"$*" `
Lets me just enter last part of the file, and there it is.

I would like to
1) check to see if the script returns more than one result, if so echo them, so I can narrow it down.
2)If return is null (no matching file), check in a 2nd directory. If still not found, echo a warning and exit, do not display the blank tmp file. I don't expect anyone to do it for me, just some opinions, keywords or links will work. I usually would use perl for something like this, but I want to learn some shell scripting as well, TIA-. Not sure if it's important, but OS=RedHat

Joe

Because a thing seems difficult for you, do not think it impossible for anyone to accomplish.
Marcus Aurelius
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top