bash template: Script with one argument

Use this template to create a bash / shell script with one argument that prints a usage message if used with the wrong number of arguments:

bash_one_arg_template.sh
#!/bin/bash
if [ $# -ne 1 ]
then
    echo "Usage: $0 <filename>"
    exit 1
fi
# Note: The argument is $1
# TODO: Place your code here

 


Check out similar posts by category: Shell