source: trunk/Cosy/tpoint/joinfiles.sh@ 19622

Last change on this file since 19622 was 8568, checked in by tbretz, 17 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/bin/sh
2
3function usage()
4{
5 echo
6 echo "Usage: $0 starg|tpoint yyyy mm"
7 echo
8 echo " starg|tpoint which kind of file you are going to join."
9 echo " yyyy year you want to join in four digit notation."
10 echo " mm month you want to join in two digit notation."
11 echo
12}
13
14if ! [ `echo $@ | wc -w` -eq 3 ]
15then
16 usage
17 echo ERROR: Wrong number of commandline argument.
18 echo
19 exit
20fi
21
22if ! [ `echo $2 | wc -c` -eq 5 ]
23then
24 usage
25 echo ERROR: Year must have four digits.
26 echo
27 exit
28fi
29
30if [ `echo $3 | wc -c` -gt 3 ]
31then
32 usage
33 echo ERROR: Month must not exceed 2 digits.
34 echo
35 exit
36fi
37
38year=$2
39month=`printf %02d $3`
40type=$1
41
42output=$1$year$month.txt
43
44path=/magic/subsystemdata/drive/$year/$month
45
46echo
47echo Processing $path.
48
49files=(`find $path -name $1_$year$month*.txt -printf %P\\\n`)
50
51if [ ${#files[@]} -eq 0 ]
52then
53 echo WARNING: No $1 files found.
54 echo
55 exit
56fi
57
58#if [ -e $output ]
59#then
60# echo
61# echo File exists
62#fi
63
64rm -f $output
65
66echo Writing $output.
67
68head -n 3 $path/${files[0]} >> $output
69
70for file in ${files[@]}
71do
72 echo Reading $file...
73 echo >> $output
74 echo -n "# " >> $output
75 head -n 3 $path/$file | tail -n 1 | cut -d\ -f 4- >> $output
76 tac $path/$file | head -n -3 | tac >> $output
77done
78
79echo Done.
80echo
Note: See TracBrowser for help on using the repository browser.