forked from michael-cannon/skel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diffcopy
executable file
·39 lines (31 loc) · 972 Bytes
/
diffcopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Read in a file, vimdiff custom file with original, then cp revised original to
# custom file name
#
# @author Michael Cannon <[email protected]>
if [ -z "${1}" ]
then
echo "Usage: `basename $0` custom_templates_listing"
echo Read in a file, vimdiff custom file with original, then cp revised original to custom file name
echo
echo "Example: `basename $0` ./customized-files.txt"
exit
fi
# read in file
FILE=${1}
# cycle through entries
for ENTRY in `cat ${FILE}`
do
# ENTRY is custom file
# create original file name from custom
# remove ".custom" from custom file for original file name
ORIGINAL=`echo ${ENTRY} | sed -e "s#\.custom\.#.#g"`
# create original copy as well prior to editing
# run vimdiff
vimdiff ${ENTRY} ${ORIGINAL}
# cp custom file to ".custombak" file name
CUSTOMBAK=`echo ${ENTRY} | sed -e "s#\.custom\.#.custombak.#g"`
cp ${ENTRY} ${CUSTOMBAK}
# cp new original back to ".custom" file name
cp ${ORIGINAL} ${ENTRY}
done