I am trying to create a small program to count the no of lines in a set of log files based some user supplied time frame.I am currently in the last step and due to some reason when i execute the program it fails with the below error grep: |: No such file or directory grep: wc: No such file or directory
The execution happens at line 6 in the code below. Line 7 shows a sample command that i am trying to execute. If I comment line 6 and uncomment line 7, it executes. I might be missing something simple. Appreciate your help. The values on those variables are given below
fileName="' summary_* | wc -l" command="grep '" comm=ived>20161215110
1 for (( z=0; z<($interval/10); z++ ))
2 do
3 comm=$tempCommand$count
4 let "count = $count + 1"
5 #echo "$command$comm$fileName"
6 totalCount=`$command$comm$fileName`
7 #totalCount=`grep 'ived>20161215110' summary_* | wc -l`
8 echo $totalCount
9 done
grep ... | wc -l
might be simplified to justgrep -c ...
grep | wc -l
when you couldgrep -c
? Also, I would throw in some debug output that shows the contents of$command
,$comm
, and$filename
.