Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The trickiest part of Bash I know is that "$(command)" results in the truncation of the output of the command before the newline. It's both handy and damning depending on what you're trying to do.


I don't think that's correct, do you have an example? This works for me:

  $ var=$(echo $'a\nb')
  $ echo "$var"
  a
  b


Oh, I meant before the trailing newlines, sorry for being unclear. Try using a\nb\n\n\n instead of a\nb and observing that the output doesn't change.


Ah, okay, got it. Yes, that can be surprising.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: