xxxxxxxxxx
#FIRST METHOD
Hello () {
echo 'Hello Wordl'
}
Hello
#SECOND METHOD
function Hello {
echo 'Hello Wordl'
}
Hello
xxxxxxxxxx
foo () {
echo $1 # $1 is the first argument
}
foo
# alternative way
function foo {
echo $1
}
foo
xxxxxxxxxx
#!/bin/bash
#Call a function without arguments
function quit {
exit
}
#Call a function with arguments
function e {
echo $1 #$1 will be set to the first argument given
}
xxxxxxxxxx
func1(){
#some function thing
function2(){
#second function thing
}
}
xxxxxxxxxx
killport(){
sudo kill -9 $(sudo fuser -n tcp $1 2> /dev/null);
}
Now put this function in your bash configuration file, eg ~/.bashrc and then run:
source ~/.bashrc