Dear All:
I Have a bunch of files which I'd like to process with a shell script. The problem is that the files have strange characters in their headers, like
g8@L-000-MSG2__-ABCD________-FIRA_____-000001___-200806181330-__
e
Data from BLABLABLA, Instrument: BLABLA, Date: 2008/06/18 13:30Z
Row: 1078 Col: 1130 Lat: -22.267 Lon: 22.256 *** Something here ***
For my intents, I only need the information (in this case) from line 3 onwards. Sometimes this strange header occupies 2 lines, others 3...others...I don't know.
I made a very simple test, like
FILE=`find . -type f -name "FILENAME"`
for i in $FILE
do
FNOW=`echo $i`
#Cuts two first lines of the file
sed '1,2d' $FNOW > newfile
sed '/^$/d' -i newfile
HEADER=`head -1 newfile | cut -c1-4`
if [ "$HEADER" != "Data" ]
then
sed '1d' -i newfile
sed '/^$/d' -i newfile
fi
#A simple testing
HEADER2=`head -1 newfile | cut -c1-4`
echo ${HEADER2},${HEADER} >> test.txt
done
The problem is that.....sometimes i don't get to cut all the "strange" headers to obtain "clean" files, as you can see in some lines of test.txt
Data,@H
Data,
Data,Data
Data,@H
(etc)
So:
Is there any way to fulfill my intentions with sed? Maybe some "delete all the first lines until find the expression �Data�? Honestly, i don't know what else to try.
Thank you very much in advance