0

Why are newlines not printed when calling echo "$var" ?

chart ()
 {
  local var="
 find ~/Opstk/bin/gadin-1.0/ -name '*.rc' -exec \
   grep -C MYVAR {} \+"

  echo "$var"
 }
Vera
  • 1,173
  • 4
  • 17
  • 1
    What newlines? There is one newline in your string (at the start), and `echo` adds another one at the end. Also, just because it feels like this will be the next question: [How can we run a command stored in a variable?](https://unix.stackexchange.com/q/444946) – Kusalananda Jan 28 '23 at 06:15
  • 1
    The current question is most likely a duplicate of [can not understand backslash newline in bash double quotes](https://unix.stackexchange.com/q/359509) – Kusalananda Jan 28 '23 at 06:20
  • I think you figures the problem. That the inclusion of `\\` puts the echo on same line. – Vera Jan 28 '23 at 06:29

0 Answers0