Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88c204a

Browse files
author
Ankam Ravi Kumar
authored
Create functions.sh
1 parent 635037f commit 88c204a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

functions.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
#Purpose: Example for Functions
3+
#Version:1.0
4+
#Created Date: Sat May 26 00:17:19 IST 2018
5+
#Modified Date:
6+
#WebSite: https://arkit.co.in
7+
#Author: Ankam Ravi Kumar
8+
# START #
9+
function takebackup (){
10+
if [ -f $1 ]; then
11+
BACKUP="/tmp/$(basename ${1}).$(date +%F).$$"
12+
echo "Backing up $1 to ${BACKUP}"
13+
cp $1 $BACKUP
14+
fi
15+
}
16+
17+
takebackup /etc/hosts
18+
if [ $? -eq 0 ]; then
19+
echo "Backup Success"
20+
fi
21+
# END #

0 commit comments

Comments
 (0)