unix - How to store the value of cat command in the variable var? -


i'm trying find number of times string repeated in file, @ same time i've store in variable.

when use command (cat filename | grep -c '123456789') , displays count correctly when use below command shows command not found.

var =$(cat filename | grep -c '123456789') echo $var 

can u let me know i'm wrong ?

don't use spaces around = sign:

var=$(cat filename | grep -c '123456789') 

read @ least bash prog intro howto

but you've got useless use of cat code simply

    var=$(grep -c '123456789' filename) 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -