I have a shell-script which extract details from a log file between two dates and executes a command on the output to generate some report.The log files are on different server and scripts are executed on different server. the Script looks like :
#!/bin/sh
time1=$1
time2=$2
echo `ssh -i key user@ip -yes cat file | awk '{if(substr($4,2)>="'$time1'" && substr($4,2)<="'$time2'") print $0;}'` > tmp.log
`cat tmp.log | some operation to get detail`
The output expected to be like :
ip1 date1 - - request1 file1 method1 status1
ip2 date2 - - request2 file2 method2 status2
i.e. multiple lines but the output generated is a single line containing all the details like:
ip1 date1 - - request1 file1 method1 status1 ip2 date2 - - request2 file2 method2 status2
When running the same command directly on the server its generate desired output but not when executed remotely.
So my question is how would I get the correct output and is this a good way to do this ?