This post was originally published on my blog, find original post here.
I have been executing a lot of bash scripts and one-off processes on the l...
For further actions, you may consider blocking this person and/or reporting abuse
Current style recommendations for shell scripts discourages the use of back-ticks. One would more typically do something like:
Using the
$()
method allows for nesting of commands without jumping through hoops to escape one command-execution nested within another)Thanks for the tip Thomas. I usually do use
$()
but didn't know that you don't need to escape nested command execution with it. Initially I used$()
along with{}
and it lead to errors on Mac (but not on Linux), so I switched to back-ticks which worked on both.I'll update the article once I get near my computer and can test this out on both Mac and Linux, thanks again.
Yeah... Being a long-time abuser of nested subshells, used to frustrate the hell out of me once I had to go more than about two subshells deep ...Sooner if one or more of those subshells required single- and/or double-quotes for some of their functionality.
Wasn't really until I started adding shellcheck to my TravisCi recipes that I habituated to the
$()
method. That tool also caused me to start moving off a few other habitual things that had been placed on the deprecation (but had worked for decades so were just "finger memory").I'd definitely suggest checking out glances: It's an alternative to
top
/htop
entirely written in Python, and it's a lot easier on the eyes/to parse IMO.Nice tip