How to Build Better Shell Scripts

The UNIX philosophy involves building tools that can do one job really well, writes Cherry Ramatis.

“Sometimes you're writing a tool and quickly observe that the scope got bigger while you were writing it, now what should be a small tool is growing to be a big project with various interactive steps,” Ramatis says. At that point, you might want to just keep adding subcommands, but “writing a tool that does one thing right is more valuable than writing a gigantic behemoth.”

This article explains the general Unix philosophy, explores key elements of a well-written script, and looks at building blocks of scripting such as the pipeline operator, stdin, and stdout manipulation. 

Learn more at Dev.to.

See also:
6 Steps to Teach Yourself System Administration
Dynamic Bash Prompts to Customize the Command Line
How to Build a Simple Script on a Unix or Linux System
Linux Text Processing and Filtering
 

Contact FOSSlife to learn about partnership and sponsorship opportunities.

Comments