Site icon New Generation Enterprise Linux

Stop using backticks for command substitution: your shell is begging you to switch

Shell Scripting & Automation

Stop using backticks for command substitution: your shell is begging you to switch

Technical Briefing | 10/15/2026

I still see scripts in production that look like they were written in the late nineties. The most common offender is the backtick used for command substitution. It is not just about aesthetics. Backticks make nesting commands a nightmare of escaping that will inevitably break when you move from simple commands to anything requiring quoted arguments.

Why backticks are a trap

When you use backticks, you have to escape every single backslash and backtick inside the block if you want it to survive a subshell. It gets messy fast. I have spent hours debugging scripts where a nested variable expanded at the wrong time because the backticks caused the shell to evaluate everything twice. The modern alternative is the dollar-parenthesis syntax. It is cleaner, easier to read, and it handles nesting natively without turning your code into a mountain of escape characters.

OUTPUT=$(grep 'error' $(find /var/log -name '*.log' -mtime -1))
  • Dollar-parenthesis supports native nesting without extra backslashes
  • It is clearly visible in text editors unlike backticks which look like single quotes
  • It aligns with POSIX standards for modern shell environments
  • It avoids the double-evaluation headache during complex piping

Next time you find yourself hitting the key above your tab key, stop. Rewriting that existing legacy script might seem like busywork, but you will thank yourself the next time you have to debug a command that is three levels deep. If it works today, that is great, but make your future self’s life easier by using syntax that actually behaves predictably.

Linux Admin Automation  |  © www.ngelinux.com  |  10/15/2026
0 0 votes
Article Rating
Exit mobile version