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