Skip to main content
deleted 28 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 238

I am new to shell scripting. 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

I am new to shell scripting. 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

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
added 122 characters in body
Source Link
Shawn
  • 133
  • 1
  • 7

I am new to shell scripting. 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

I am new to shell scripting. 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

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

I am new to shell scripting. 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
Source Link
Shawn
  • 133
  • 1
  • 7

Grep Command execution within a loop gives error

I am new to shell scripting. 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

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