source: ccr2ccd-xslt/trunk/make/LineNumberDownFunction@ 1482

Last change on this file since 1482 was 1033, checked in by mishpers@gmail.com, 14 years ago

Add missing files that were on Nancy's local computer

File size: 2.2 KB
Line 
1#!/bin/bash
2#Takes the $1 argument of the beginning line number, and the
3# $2 argument of the element you are looking for
4# $3 is the name of the file
5LineNumberDownFunction ()
6{
7echo "arguments are $1 $2 and $3"
8
9local BeginLineNumber
10#BeginLineNumber=""
11BeginLineNumber="$1"
12
13local EndSectionElement
14#EndSectionElement=""
15EndSectionElement="$2"
16
17local File
18#File=""
19File="$3"
20
21local FoundEndSectionElement
22FoundEndSectionElement=""
23
24local EndLineNum
25#EndLineNum=""
26local LineNum
27
28local EndSectionLineNumber
29#TestSectionInformation=""
30echo "file is $File"
31LineNum="$BeginLineNumber"; echo "BeginLineNumber is $BeginLineNumber"
32#read
33#initialize EndLineNum which will ultimately be the line with the ending component tag, "$EndSectionElement"
34EndLineNum="$(($LineNum+1))"; echo "EndLineNum is $EndLineNum"
35#This is to check the line and if it does not contain $EndSectionElement, add 1 to EndLineNum and go to the next line and check that one
36head -"$EndLineNum" "$File" | tail -1| grep -q "$EndSectionElement" > /dev/null
37FoundEndSectionElement="$?"
38#FoundEndSectionElement="$(head -"$EndLineNum" "$File" | tail -1| grep -q "$EndSectionElement";echo "$?")"
39#FoundEndSectionElement="$(sed -n "$EndLineNum"p "$File" | grep -q "$EndSectionElement";echo "$?")"
40echo "FoundEndSectionElement is $FoundEndSectionElement"
41#read
42while [ "$FoundEndSectionElement" = "1" ];
43do
44 EndLineNum="$(($EndLineNum+1))"
45 echo "EndLineNum is $EndLineNum"
46 # echo "$(head -"$EndLineNum" "$File" | tail -1)"
47 head -"$EndLineNum" "$File" | tail -1 | grep -q "$EndSectionElement"
48 FoundEndSectionElement="$?"
49 #FoundEndSectionElement="$(head -"$EndLineNum" "$File" | tail -1 | grep -q "$EndSectionElement";echo "$?")"
50 echo "FoundEndSectionElement is $FoundEndSectionElement and the EndSectionElement is $EndSectionElement and current line being tested is $EndLineNum"
51done
52echo "Beginning line Number of the Section is $BeginLineNumber"
53EndSectionLineNumber="$EndLineNum"
54echo "Ending Line Number of the Section is $EndSectionLineNumber"
55
56TestSectionInformation=$(echo "$BeginLineNumber:$EndSectionLineNumber:$EndSectionElement:$File")
57echo "end LineNumberDownFunction"
58
59}
Note: See TracBrowser for help on using the repository browser.