Friday, April 1, 2016

Linux Bash Shell Script Function Argument Passing Examples


Code Function Argument To Read Argument File From Terminal line by line:

Save the code in a file named "FunctionArgumentPassing1.sh".

Running the Code:

Just type the code below in terminal. Make sure to cd into that directory if you have not opened the terminal in that directory. Make sure to create the "log.txt" file in the same directory as the shell script file.

bash FunctionArgumentPassing1.sh

Sample Input File:

Save as "log.txt".

Code Function Argument Traverse Directories Recursively:

Save the code in a file named "FunctionArgumentPassing2.sh".

Running the Code:

Just type the code below in terminal. Make sure to cd into that directory if you have not opened the terminal in that directory. Make a directory named "deletefolder" with more directories inside and inside them some files.

bash FunctionArgumentPassing2.sh

No comments: