-
Notifications
You must be signed in to change notification settings - Fork 0
/
ICV_Tabledir.sh
48 lines (30 loc) · 1.05 KB
/
ICV_Tabledir.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
#!/bin/bash
#find sub1/* -type f -printf "%f\n" | paste -s -d , > data.csv
eval "dirs=($(ls -v --quoting-style=shell-always))"
headers_done=false
for dir in "${dirs[@]}"; do
eval "files=($(
ls -vd --quoting-style=shell-always -- "$dir"/LABEL_*.txt))"
if ! "$headers_done"; then
printf SubjectID
printf ',%s' "${files[@]}"
printf '\n'
headers_done=true
fi
printf %s, "$dir"
tail -q -n 1 -- "${files[@]}" | paste -sd , -
done > Output_volumes.csv
#echo "SubjectID" > temp
#find . -type d -iname "subject*" | sed 's/^.*\///' >> temp
# eval "dirs=($(ls -v --quoting-style=shell-always))"
#for dir in "${dirs[@]}"; do
# eval "files=($(
# ls -vd --quoting-style=shell-always -- "$dir"/t1/regional_vol*.txt))"
#tail -q -n 1 -- "${files[@]}" | paste -sd , -
#done > data.csv
#paste -d, <(ls -1v "$dir"/t1/regional_vol*.txt ) > data.csv
# paste -d , temp <(sed '/^\s*$/d' data.csv)
# mv data.csv temp.csv
#x,regional_vol_GM_atlas1.txt,regional_vol_GM_atlas2.txt
#sub1,1 1,2 2
#sub2,3 3,4 4