forked from meom-group/DCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdcmtk_chkunlim
executable file
·52 lines (46 loc) · 1.45 KB
/
dcmtk_chkunlim
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
#!/bin/bash
# this script establish the list of nc files with bad problems ( time dimension is 0 )
# it must ne run in any directory containing nc files
# if used with -v option also print the UNLIM line of the file
# class = @File management tools@
usage() {
echo
echo "USAGE : dcmtk_chkunlim [-h ] [-v] [-p pattern] [-e ext] "
echo
echo " PURPOSE:"
echo " Scan the nc files in the current directory, and check if UNLIMITED "
echo " dimension is different from 0."
echo " With no option, gives the name of corrupted files (UNLIMITED dim = 0 ) "
echo " "
echo " OPTIONS :"
echo " -h : print this usage message"
echo " -v : print the UNLIMITED line for all files"
echo " -p pattern : use pattern for filtering the files to scan "
echo " -e ext : use ext as the extension of the file (default: .nc)"
echo " "
exit 0
}
lverbose=0
pattern=''
ext='.nc'
while getopts :hvp:e: opt
do
case $opt in
(h) usage ;;
(v) lverbose=1 ;;
(p) pattern=$OPTARG ;;
(e) ext=$OPTARG ;;
(*) ;;
esac
done
if [ $lverbose = 0 ] ; then
for f in *$pattern*${ext} ; do
ncdump -h $f | grep UNLIM | tr -d '(' |\
awk '{ if ( $(NF -1) == 0 ) print fich " : " $0 }' fich=$f
done
else
echo Verbose ...
for f in *$pattern*${ext} ; do
echo -n $f " : " ; ncdump -h $f | grep UNLIM
done
fi