Bash Script it possible?
Page 1 of 1

Author:  Flux [ Wed Jan 20, 2010 9:30 am ]
Post subject:  Bash Script it possible?


This is my first forum post so be gentle!

Basically, I have a directory with many log files inside. They are all of the same type and of similar naming convention (1-2010-log, 2-2010-log etc.)

I want to create a simple front-end script which will let me access any file in the directory without having to enter the complete path. For example, if I were to simply run the script by typing a simple command then it would ask me which file I wanted to access. After inputting the file name it would open up the file in nano or vi or something similar.

Could I do this with a bash script or would Python or Perl be a better option?



Author:  crouse [ Fri Jan 22, 2010 10:05 pm ]
Post subject:  Re: Bash Script it possible?

A simple bash script would be easy enough to do.
Hopefully this isn't homework, although this is probably too easy for homework, sooo

ls /path/to/your/directory
read -p "Which file do you want to open? :" this_file
nano /path/to/your/directory/${this_file}
exit 0

ls /path/to/your/directory -- this line lists your directory of files
read -p "Which file do you want to open? :" this_file -- this line allow you to choose your file
nano /path/to/your/directory/${this_file} -- this line opens the file in nano, you could of course change this to vi,emacs, whatever floats your boat. :)

Author:  Flux [ Sun Jan 24, 2010 9:47 am ]
Post subject:  Re: Bash Script it possible?


That works great.Just what I was looking for.


Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group •