Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
dataflow
on Jan 6, 2018
|
parent
|
context
|
favorite
| on:
Things I Wish I'd Known About Bash
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.
bewuethr
on Jan 7, 2018
[–]
I don't think that's correct, do you have an example? This works for me:
$ var=$(echo $'a\nb') $ echo "$var" a b
dataflow
on Jan 7, 2018
|
parent
[–]
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.
bewuethr
on Jan 7, 2018
|
root
|
parent
[–]
Ah, okay, got it. Yes, that can be surprising.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: