Bash script to view log and config file in different server and paths.

2010-03-09 141 words 1 min read

I was working on a project, where I need to open file from different servers and different paths. I do it with the command:

vim ftp://username@server/path/filename

This is okay when the path is short but when the path gets longer and I have different config files to open from the same path or their associated logs, then it becomes un-necessary typing. So, I did the following:

Have a file with some aliase’s like the below and source it from the bashrc file:

conf_app1=dns #this is with path

conf_app2=host

log_app1=dns #this too is with path

log_app2=hosts

And then I have a bash script that will use these variables to open the file required. I use the format as

view.sh c/l app1

where c/l denotes whether I want to open the config file or the log file. Download the script <a href="http://blog.amit-agarwal.co.in/wp-content/uploads/2009/09/view.sh">here.


Tags: bash

author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it