I saw similar questions, but none of the solutions seem to work in this case. I have a text file that looks something like this.
START-OF-FILE
RUNDATE=20140910
FIRMNAME=dl
FILETYPE=pc
REPLYFILENAME=TEST
DERIVED=yes
PROGRAMFLAG=oneshot
SECID=ISIN
SECMASTER=yes
PROGRAMNAME=getdata
START-OF-FIELDS
ISSUER
START-OF-DATA
US345370CN85|0|4|FORD MOTOR COMPANY|FORD MOTOR COMPANY| | |
US31679BAC46|0|4|FIFTH STREET FINANCE COR|FIFTH STREET FINANCE COR| | |
END-OF-DATA
END-OF-FILE
I am trying to write a bash shell to extract only text between "START DATA" and "END DATA", with the exception of both. So the output I'm looking for will look like this:
US345370CN85|0|4|FORD MOTOR COMPANY|FORD MOTOR COMPANY| | |
US31679BAC46|0|4|FIFTH STREET FINANCE COR|FIFTH STREET FINANCE COR| | |
The code I have written so far is as follows
while read line
do
name=$line
echo $name | sed -e 's/START-OF-DATA\(.*\)END-OF-DATA/\1/'
done < $1
and run it from bash e.g.
./script.sh file.txt
script.sh - , script as, file.txt - , . . , - . .