Tips: Do-nothing Scripting in Bash
code
bash
beginner
tips
Do-nothing scripting is a nice way to blend documenting a protocol with running it. You can use this template as a place to start:
#!/usr/bin/bash
#-----------------------------------------------------------------------------#
STEP='Step 0:'
echo "$STEP"
echo "Run? (y/n)"; read -n 1 k <&1
if [[ $k = n ]] ; then
printf "\nSkipping $STEP\n"; fi
else
printf "\nDoing $STEP\n"
# Code for step here:
Note, having the condition be on n instead of yes allows for the code (which will vary in length) to be at the end. This makes the control flow easy to see.