EanderAlx.org

Linux, Virtualization and whatever I find interesting ...

User Tools


Site Tools


bashscr:functions

Bash - Functions

  • How to use functions in bash

  • Here an example: you can pass values returned by programms as parameter to check them.
#Functions======================================
function check() {
	FC=$1
	if [ $FC != "0" ];then
           echo -e "--> ERROR\n"
	else
	   echo -e "--> OK\n"
	fi
	}
#============================================
  • You can use the function by its name with parameter (here an exit code) e.g.: check “$?”
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
bashscr/functions.1285781892.txt.gz · Last modified: 29.09.2010 19:38 by eanderalx