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 :: git use ssh instead of https 
Shell :: express js 
Shell :: mac see current path 
Shell :: how to install onnx on jetson nano 
Shell :: git revert back to specific commit 
Shell :: rails reset gemfile.lock 
Shell :: switch user in windows 10 
Shell :: chmod add execute permission to useer 
Shell :: how to reset ubuntu 20.04 
Shell :: create md5 hash command line 
Shell :: Cannot install windows-build-tools 
Shell :: docker compose install centos 8 
Shell :: how to install any package in node.js 
Shell :: github desktop arch linux 
Shell :: install rstudio ubuntu 20.04 
Shell :: vim open new tabs 
Shell :: how to echo string .sh 
Shell :: git bash gradle weird characters 
Shell :: mac compress tar.gz pc 
Shell :: start arangodb 
Shell :: git ignore already pushed file 
Shell :: vmd in terminal 
Shell :: docker install 
Shell :: connectify alternative for linux 
Shell :: * daemon not running; starting now at tcp:5037 
Shell :: react native reactotron bug 
Shell :: centos 7 ius-release.rpm 
Shell :: install aptitude debian 
Shell :: git reset specific file 
Shell :: print in bash 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =