-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup_list_maker.sh
34 lines (30 loc) · 1.2 KB
/
backup_list_maker.sh
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
#!/bin/sh
### # # # # # # # # # # # #
###
### This script makes backup target directry path list.
###
### This script works with following flow.
### 1. Get target directory names from a file named as BACKUP_TARGET_DIR_LIST.
### 2. From the upper directory name described in BACKUP_TARGET_LIST, write the path of the subdirectory in the upper directory to each file named with the upper directory name.
###
### Preparation
### 1. Set directoroy name to backup in a file named as BACKUP_TARGET_DIR_LIST at directry which this script is.
### 2. Make directory named as backup_lists at directry which this script is.
### # # # # # # # # # # # #
# Set parameters
HOME_DIR="/Users/Taiti"
BACKUP_LISTS="backup_lists"
# Delete old lists
while read DIR_NAME
do
rm ./$BACKUP_LISTS/$DIR_NAME
done < BACKUP_TARGET_DIR_LIST
# Make lists
while read DIR_NAME
do
# If listed object is a directory, first section of output text by command`ls -l` is 'd'.
for dir in `ls -l $HOME_DIR/$DIR_NAME | awk '$1 ~ /d/ {print $9 }'`
do
echo $dir >> ./$BACKUP_LISTS/$DIR_NAME
done
done < BACKUP_TARGET_DIR_LIST