Reputation: 2436
I'm new to it. x can not be recognized from above statement. What is the problem?
x = find . -name "*.java" | wc -l
echo $x
Upvotes: 0
Views: 507
Reputation: 32873
It should be
x=$(find . -name "*.java" | wc -l)
(Note that there is no space around the =
sign)
To answer your question, the problem is
the space after x
causes the shell to try to execute the command x
which probably does not exist
you want the result of the command to be stored in x
, so you need to execute the command (hence the $(...)
)
Upvotes: 5