re: Monitor the performance of any command line program with this single command VIEW POST

VIEW FULL DISCUSSION
 

Current style recommendations for shell scripts discourages the use of back-ticks. One would more typically do something like:

top -p $( gunzip -c LARGE_ARCHIVE_FILE.tgz > /dev/null & echo $! )

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").

code of conduct - report abuse