#!/bin/bash #=============== function function add { ... # the cmd line inspired by sequence 3 } #=============== main if .... ; then. # number of args is greater than 0 for item do if .... # item is a file ? then ... # error message .... # stop the script with exit status to 1 fi done sum=... #call add function else sum=... #call add function and use stdin fi echo "sum = $sum" exit 0