Files
shell-scripting-tutorial/function.sh
2024-09-21 00:44:20 +05:30

28 lines
548 B
Bash

#!/bin/bash
#Purpose: Function example. Taking Backup of Particular File
#Version:1.0
#Created Date: 2024 Sep 21
#Modified Date:
#WebSite: https://arkit.co.in
#Author: Ankam Ravi Kumar
# START #
function takebackup (){
if [ -f $1 ]; then
BACKUP="/home/aravi/$(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
function testing (){
echo "Just TEsting Function"
}
testing
# END #