mirror of
https://github.com/techarkit/shell-scripting-tutorial.git
synced 2025-08-03 07:34:30 +00:00
Create functions.sh
This commit is contained in:
21
functions.sh
Normal file
21
functions.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
#Purpose: Example for Functions
|
||||
#Version:1.0
|
||||
#Created Date: Sat May 26 00:17:19 IST 2018
|
||||
#Modified Date:
|
||||
#WebSite: https://arkit.co.in
|
||||
#Author: Ankam Ravi Kumar
|
||||
# START #
|
||||
function takebackup (){
|
||||
if [ -f $1 ]; then
|
||||
BACKUP="/tmp/$(basename ${1}).$(date +%F).$$"
|
||||
echo "Backing up $1 to ${BACKUP}"
|
||||
cp $1 $BACKUP
|
||||
fi
|
||||
}
|
||||
|
||||
takebackup /etc/hosts
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Backup Success"
|
||||
fi
|
||||
# END #
|
Reference in New Issue
Block a user