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
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 $(...)
)
这也应该起作用:
x=`find . -name "*.java" | wc -l`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.