Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder created called : unix_generic_function #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Generic_unix_functions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
############################################################################
# Name : Vikas Vooradi
# Email : [email protected]
############################################################################

The main purpose of creating this folder : unix_geenric_function is that
it will contain all the generic function which can be used as per the need

for example : function called : checkFileExist()

checkFileExist() : This fucntion will check the file exist at following path or not
The script will dynamically get the parameters from the command line from
the user.Then it display the status as success file exist at path or else
it prints failed the file does not exist at path.
56 changes: 56 additions & 0 deletions Generic_unix_functions/checkFileExistorNot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

checkFileExistorNot()
{

# Parameters defined
InputPath=$1
InputFilename=$2

# Checking the parameters entered from user or not
if [ -z ${InputPath} ]
then
echo "Fail : Path : $InputPath : Parameter is not defined "
else
echo "Success : Path : $InputPath : Parameter is defined"
fi

if [ -z ${InputFilename} ]
then
echo "Fail : Path : $InputFilename : Parameter is not defined "
else
echo "Success : Path : $InputFilename : Parameter is defined"
fi

[ -d $InputPath ] > /dev/null
statuschk=$?

if [ $statuschk -eq 0 ]
then

echo "Checking started ....."

# Checking the file exist at path or not
[ -f $InputPath/$InputFilename ] > /dev/null

status=$?
if [ $status -eq 0 ]
then
echo "Success : File : $InputFilename exist at following path : $InputPath"
else
echo "Fail : File : $InputFilename does not exist at following path : $InputPath"
fi

else

echo "Entered path : $InputPath does not exist, please enter valid path"

fi

}

# Calling function
checkFileExistorNot '@your_path' '@your_file_name'