-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombine_edep.sh
63 lines (52 loc) · 2.07 KB
/
combine_edep.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
62
63
# This script concatenates the output from a given number of simulations
# into one file. Call this script in the base directory of the simulation, ie
# the directory containing the sims directory.
# Usage:
# ./combine_all.sh
# ------------------------------------------------------------------------------
# Author: 07/07/2017, M. Hentz
# ------------------------------------------------------------------------------
# -----------------------------------
# #
# combine_edep.sh #
# #
# -----------------------------------
# Modified:
# 22/10/18, J. Yap
#
# This script concatenates the energy deposited per layer for a given number of simulations
# into one file. Call this in the directory of the simulation, works in the same way and is
# adapted from ./ combine_all.sh
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
#!/bin/bash
# Get total number of simulations
nsimulations=$(echo sims/* | wc -w)
file=(edep.txt)
# Iterate over the output files in first directory
for file in edep.txt;
do
# Construct output file name and save path to it
output="edep.txt"
write_to_path=combined/${output}
# Boolean used to read in header from first file and write to output file
first=1
# Iterate through the directory and write files to combined output file
for i in $(ls -v sims)
do
# If first file
if [[ ${first} -eq 1 ]]
then
# Write the header of the first file to the output file
# Currently this is the top line in the output, prepended with "#"
head -n 1 combined/${output} > ${write_to_path}
first=0
fi
path_to_file=sims/${i}/data/${output}
echo -ne " Collating output files... ${i}/${nsimulations}\r"
# Write all lines except the first to the combined file
# Assuming a one-line header
tail -n +2 ${path_to_file} >> ${write_to_path}
done
echo " Collating output files... ${nsimulations}/${nsimulations}"
done