#!/bin/bash - #=============================================================================== # # FILE: view.sh # # USAGE: ./view.sh # # DESCRIPTION: Log/Configuration file viewer. # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (AKA), amit.agarwal@amit-agarwal.co.in # COMPANY: Individual # VERSION: 1.0 # CREATED: 09/07/2009 09:51:24 AM IST # REVISION: --- #=============================================================================== usage() { echo echo "Please provide 2 inputs" echo "1st param is c or l indicating log or config file" echo "Second param is one of the below:" ## cat ~/.bash.d/S999_alias.sh|sed --silent -e '/log_|conf_/p' cat ~/.alias.sh|sed 's/^export //'|sed --silent -e '/^log_\|^conf_/p'|sed 's/=.*$//'|sed 's/log_\|conf_//' ##Give the path here for the file containing the variables, this is used for help only. } ### [ "$#" == "2" ] || ( usage; exit -1;) [ "$#" == "2" ] && ( l_c=$1 file=$2 [ x"$l_c" == "xc" ] && file="$(eval echo \${conf_$file})" [ x"$l_c" == "xl" ] && file="$(eval echo \${log_$file})" file="ftp://AmitAgarwal@$server/$file" #server is also defined in the alias file vim $file ) || usage;