0

I have an assignment where I have to put every occurence of a word starting with an l into the Variable FOO, with a new line starting after every word.

So I used grep -i -w -o "l[A-Z]*" lipsum.txt which Outputs

Lorem

labore

laboris

laborum

each in a new line. So I used FOO=$(grep -i -w -o "l[A-Z]*" lipsum.txt) and then used echo $FOO to test it, but it printed all 4 in the same line. Is this a problem with echo or is it actually like that in the variable? How do I fix it?

Potheker
  • 93
  • 8
  • Quote your variable: `echo "$FOO"`. By the way: regular variables are written in lowercase by convention `foo=...` instead of `FOO=...`. – Socowi May 17 '20 at 16:38
  • 1
    Explanation: [I just assigned a variable, but echo $variable shows something else](https://stackoverflow.com/questions/29378566/i-just-assigned-a-variable-but-echo-variable-shows-something-else) – Socowi May 17 '20 at 16:39

0 Answers0