I have some text files I need to do the following on:
Delete banner page (lines 1-56) --I am doing this using sed
Remove ^M --I am doing this using vi
Remove trailer page --this can vary based on the contents of the file, it usually starts with ***************************
I am able to do the first two steps manually by just issuing the commands against the filename, but I am wondering if there is a systematic approach that I can use to make this happen all in one simple script.
Thank you for steering me in the right direction, I think I am almost there. My goal is to take a file, "massage" it, and output the contents. I am expecting the below to massage JEFFTEST files and output JEFFTEST.TIMESTAMP (Whatever that may be)
find /opt/test -type f -name "JEFFTEST" | while read name
do
timestamp=$(date +%s)
awk '{ sub(/\r/, ""); } # Delete carriage returns
NR <= 56 { next } # Don't print lines from banner page
# Quit once you find ***********
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/ { exit }
# Otherwise, print all lines
{ print }' < $name > $name.$timestamp
done
timestamp=$(date +%s)
find /opt/test -type f -name "JEFFTEST" |
while read name
do
awk '
NR <= 56 { next } # Don't print lines from banner page
{ sub(/\r/$, ""); } # Delete carriage return at the end of the lines
# Quit once you find ***********
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/ { exit }
# Otherwise, print all lines
{ print }
' < "$name" > "$name.$timestamp"
done