-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_job_txt.sh
executable file
·61 lines (43 loc) · 1.34 KB
/
create_job_txt.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# J. Tian
# create: 19-04-12
# update: 19-04-12
if [ "$#" -ne 1 ]; then
echo "enter only one (1) argument, which is project name,
Japan_Antarctica_Project
Greeland_Project
Dome_Fuji_2019_Sounder
Dome_Fuji_2019_FMCW
Grand_Junction_2019
for example: \"sh 16_jobs.sh Japan_Antarctica_Project\""
exit
fi
project_name=$1
timestamp_file="txt.timestamps_${project_name}"
job_list="txt.job_list_${project_name}"
if [ -f ${timestamp_file} ]; then
rm -f ${timestamp_file}
fi
if [ -f ${job_list} ]; then
rm -f ${job_list}
fi
ls "/data/${project_name}" | grep -e "201[1|2]*"> ${timestamp_file}
echo "reading datasets under GPS timestamps"
while IFS='' read -r line || [[ -n "$line" ]]; do
prefix="/data/${project_name}/${line}"
# only when .dat exists can we execute commands
for i in $(ls /data/${project_name}/${line} | grep dat$); do
if [ -f ${prefix}/${line}_config.xml ]; then
echo "'${prefix}/${line}_config.xml','${prefix}/${i}'" >> ${job_list}
else
continue
fi
done
done < "${timestamp_file}"
echo "done reading all GPS timestamps"
line_count=$(grep -w "data" -c ${job_list})
line_per_file=$(echo "${line_count}/16 + 1" | bc)
echo "spliting into 16 files for scheduling"
rm -f txt.list_xml_dat_${project_name}__*
split -l ${line_per_file} -d ${job_list} ${job_list}__
rm -f ${job_list}