Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash function

foo () {
    echo $1  # $1 is the first argument
}
foo

# alternative way
function foo {
	echo $1
}
foo
Comment

bash function

#!/bin/bash

function greet {
 echo "Hi there!"
}

greet
Comment

function in bash

#FIRST METHOD
Hello () {  
  echo 'Hello Wordl'  
}  
Hello 

#SECOND METHOD
function Hello {
 echo 'Hello Wordl'
}
Hello
Comment

bash function

                #!/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
                }  
                

           
Comment

how to make a function in bash

function_name () {
<commands>
}
Comment

function in bash

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
Comment

how to make a function in bash

print_something () {
echo Hello I am a function
}
Comment

bash functions

#!/bin/bash

hello_world () {
   echo 'hello, world'
}
Comment

PREVIOUS NEXT
Code Example
Shell :: copy all files from one directory to another 
Shell :: create github repo with bash 
Shell :: alertmanager reload config 
Shell :: apply stash git 
Shell :: xargs parameter 
Shell :: Create Flask Virtual Environments 
Shell :: docker save to file 
Shell :: file system ntfs not configured in kernel 
Shell :: chsh pam authentication failure 
Shell :: check os shell liunx cygwin darwin 
Shell :: puppet install on centos 7 
Shell :: docker copy file not found 
Shell :: dateformat npm 
Shell :: Realtek RTL8812BU Network WiFi Adapter kali linux driver 
Shell :: ubuntu open with software install not working 
Shell :: how many number of lines in a file 
Shell :: Git push --help fast-forwards 
Shell :: Git lab global setup 
Shell :: powershell script for task scheduler 
Shell :: cat command in linux 
Shell :: install hass.io docker raspberry pi 
Shell :: wsl access network share 
Shell :: how to know expire date for user linux 
Shell :: git config --list 
Shell :: digitalocean connect via ssh 
Shell :: get current path unix 
Shell :: du folder size 
Shell :: how to start elasticsearch correctly 
Shell :: install ubuntu gui on wsl 
Shell :: cannot update paths and switch to branch at the same time 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =