The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: grep wc
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 09-04-2007
rorey_breaker rorey_breaker is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 20
Angry continuing problems

Hello again,
Havent responded for a while not had much time to play with this lately. And now that I return to have another go, I have the same problem.

lineno= grep -c '$user' '$file'

I don't think it is reading the file variable correctly, as at the top i have added:

echo "$file"

which returns what I expect it to, confirming that the file given by the user is valid and its reading the variable and not looking for the word file.

But when it comes to the grep count:

grep: $file: No such file or directory

username: line 26: [: 1: unary operator expected

Am I correct in thinking that the unary operator error is a result of the lineno variable being stored as a string and not as a int?

Please can someone confirm the line which will store the total count of the grep command taking user and file as arguments in a varable called lineno. This is driving me potty!!

Thanks for any help!