How to redirect grep output to a variable?

前端 未结 1 779
余生分开走
余生分开走 2021-01-18 21:38

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:

相关标签:
1条回答
  • 2021-01-18 22:26
     month=$(cal | head -1 | grep -oP "[A-Za-z]+")
    

    or

     month=$(date +%B)
    
    0 讨论(0)
提交回复
热议问题