How do I redirect grep output to a variable?
I have a pipe. For example, I have this pipe:
user@user:~$ cal | head -1 | grep -oP "[A-Za-z]+"
For this channel, I get this result:
September
I want to store this result in a variable. I write the following commands:
user@user:~$ cal | head -1 | month=$(grep -oP "[A-Za-z]+") | echo $month
And I am getting an empty string. What is the problem?
+3
source to share