Creating a function in bash, with if statements.
Functions in the Bourne-again shell.
Date Created:Sunday March 11th, 2007 02:17 PM
Date Modified:Saturday August 02nd, 2008 04:05 PM
#!/bin/bash
funcdan () {
if [ "$2" ]
then
echo Too many args!
exit
fi
if [ -z "$1" ]
then
echo zero arguments!
else
echo two arguments!
fi
return 0
}
mang=$@
funcdan $mang
Downloads:
Download: function.sh 194 B
Please login or Click Here to register for downloads
Function in BASH by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com
