mirror of
https://github.com/techarkit/shell-scripting-tutorial.git
synced 2025-07-28 23:28:40 +00:00
22 lines
459 B
Bash
22 lines
459 B
Bash
#!/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 #
|