Linux, Virtualization and whatever I find interesting ...

User Tools

Site Tools


Bash - Functions

  • How to use functions in bash

  • Here an example: you can pass values returned by programms as parameter to check them.
function check() {
	if [ $FC != "0" ];then
           echo -e "--> ERROR\n"
	   echo -e "--> OK\n"
  • 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.txt · Last modified: 23.03.2013 18:22 by eanderalx