Home > Back-end >  Store output of a command in a variable
Store output of a command in a variable

Time:10-04

In my mac terminal I am trying to store the output of a command into a variable like this

$ animals=$(cat animals.txt | head -n $plusOne | tail -n $numberofanimals | sort -u | sed -E "s/[*#/@2]//g; s/D/d/g ; s/G/g/g ; s/E/e/g ; s/H/h/g ; s/O/o/g ; s/C/c/g ; s/[!]//g”)
> 

but it does not work. When I press Enter I get a > prompt on the next line. Any idea why?

CodePudding user response:

You've got a smart quote at the end of the line instead of a regular double quote ".

  • Related