Answers for "bash function arguments"

5

bash function

function hello {
	echo Hello
}
hello
function e {
	echo $1  # $1 is the first argument
}
e Hello
Posted by: Guest on October-16-2020
1

bash pass all arguments

source script.sh "[email protected]"
Posted by: Guest on June-07-2020
3

bash function arguments

#!/usr/bin/env sh

foo 1  # this will fail because foo has not been declared yet.

foo() {
    echo "Parameter #1 is $1"
}

foo 2 # this will work.
Posted by: Guest on March-24-2021
4

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
                }
Posted by: Guest on March-15-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language