0

I'm a linux noob.

When I type echo $(cal) in bash it prints calendar without any formatting.

But when i type echo "$(cal)" it prints the complete formatted calendar.

What is the distinction between these 2 commands ?

btw, this case is described in the book The Linux Command Line by William E. Shotts, Jr. [in 7th chapter's command substitution section ] but I couldn't get it :(

meeso2004
  • 1
  • 1
  • [shellcheck.net](https://www.shellcheck.net) is good at pointing out common mistakes like missing quotes. It'll also point out that `echo "$(somecommand)"` is just an overcomplicated way to run `cal`. I recommend running your scripts through it, at least until you get more experience. – Gordon Davisson Aug 17 '21 at 06:34
  • 1
    See also: [Quoting within $(command substitution) in Bash](https://unix.stackexchange.com/q/118433/170373) – ilkkachu Aug 17 '21 at 08:21

0 Answers0