-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionlibrary.sh
More file actions
24 lines (24 loc) · 813 Bytes
/
Copy pathfunctionlibrary.sh
File metadata and controls
24 lines (24 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#------- FUNCTION LIBRARY --------
# Generic Functions that will be used in functions
#--------------------------------
# Will use stat command on the file name in argument 1.
# Will pipe it through grep and using cut command to
# cut the delimiter ' '. After that it will put it in
# multiple variables depending on Month and Day of month.
getStat () {
Date=$(stat ${LOC}/${1} | grep "Modify: " | cut -d' ' -f2,2)
NDATE="${Date#*-}"
Month=$(echo ${NDATE%%-*})
NDATE=$(echo ${NDATE#*-})
Day=$(echo ${NDATE})
}
# Depending on method used, files will either be copied or moved
# to the location
# Positional Arguments, 1 - 2 are directories, 3 is file name, 4 is method
moveCopy(){
if [[ $4 -eq 0 ]]; then
mv -f ${LOC}/${3} ~/${1}/${2}/${3}
else
cp -pf ${LOC}/${3} ~/${1}/${2}/${3}
fi
}