I have a grep command script which works fine and give the correct results but i wanted the output to be displayed in tabular format ? Is it possible to display
the output in tabular format and as well direct them to some file.
main script :
#!/usr/bin/bash
Start_Time=`date '+%m%d%y %HH%MM%SS'`
date_file=`date '+%m%d%y_%HH%MM%SS'`
Date=`date '+%m%d%y_%HH%MM%SS'`
typeset LOGFILE=/logs/`hostname`_Config_`date '+%Y%m%d_%H%M'`.log
# Logs both on screen and in to the log file
log_mode="both"
logIt (){
mydate=`date '+%Y/%m/%d %H:%M:%S'`
case $log_mode in
logfile)
printf "$mydate, $*\n" 2>&1 >> $LOGFILE
;;
screen)
printf "$mydate, $*\n" 2>&1
;;
both|*)
printf "$mydate, $*\n" 2>&1 |tee -a $LOGFILE
;;
esac
}
routes=$(grep routeList $CONFIG | grep -v '!' | grep `hostname` | cut -d ":" -f 2| sed 's/,/ /g')
logIt "========================================================="
for routeq in $routes; do
logIt "hostList/serviceList/appServiceName parameters set for the route $routeq are :"
hostList=$(grep $routeq $CONFIG | grep `hostname` | grep -v '!' | grep hostList)
logIt $hostList
serviceList=$(grep $routeq $CONFIG | grep `hostname` | grep -v '!' | grep serviceList)
logIt $serviceList
appServiceName=$(grep $routeq $CONFIG | grep `hostname` | grep -v '!' | grep appServiceName)
logIt $appServiceName
logIt "========================================================="
done
output am getting from the above script :
2013/08/30 07:25:34, ==========================================================
2013/08/30 07:25:34, hostList/serviceList/appServiceName parameters set for the route fd are :
2013/08/30 07:25:34, UHH11A*adh*fd.route*hostList : reunt.com, R0010.com
2013/08/30 07:25:34, UHH11A*adh*fd.route*serviceList : ID3
2013/08/30 07:25:34, UH11A*adh*fd.route*ID3*appServiceName : IRF
2013/08/30 07:25:35, ==========================================================
2013/08/30 07:25:35, hostList/serviceList/appServiceName parameters set for the route fd_s are :
2013/08/30 07:25:35, UH11A*adh*fd_s.route*hostList : Hnt.com,HP.com
2013/08/30 07:25:35, UH11A*adh*fd_s.route*serviceList : ATS
2013/08/30 07:25:35, UH11A*adh*fd_s.route*ATS*appServiceName : ATS
2013/08/30 07:25:35, ==========================================================
I wanted the above output in tabular form :
|=============================================|
|Server|route|hostList|serviceList|appServiceName|
|=============================================|
|UHH11A|fd|reunt.com, R0010.com|ID3|IRF |
| |fd_s|Hnt.com,HP.com |ATS|ATS |
|=============================================|