SyntaxFix
Write A Post
Hire A Developer
Questions
The syntax to store the command output into a variable is var=$(command).
var=$(command)
So you can directly do:
result=$(ls -l | grep -c "rahul.*patle")
And the variable $result will contain the number of matches.
$result