7

I have some pipe. For example, I have this pipe:

user@user:~$ cal | head -1 | grep -oP "[A-Za-z]+"

For this pipe I get this result:

September

I want to store this result to a variable. I write the following commands:

user@user:~$ cal | head -1 | month=$(grep -oP "[A-Za-z]+") | echo $month

And I get the blank string. What is the problem?

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
Denis
  • 3,595
  • 12
  • 52
  • 86

1 Answers1

15
 month=$(cal | head -1 | grep -oP "[A-Za-z]+")

or

 month=$(date +%B)
Cyrus
  • 84,225
  • 14
  • 89
  • 153