<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">I'm trying to write a bash script for something I thought would be simple, but haven't been able to figure it out.<DIV><BR class="khtml-block-placeholder"></DIV><DIV>I have some files that are essentially text files, but have binary data in them.  For instance, using grep I need to use the "-a" option to get any output.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>When one opens these files in a text editor you see a readable text file.  However, the first line of the file is a few "garbage" characters, and the last 1-10 pages are all "garbage" binary characters.  </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>All I'd like to do is make a script that would strip off the first line and then remove all the garbage characters from the end of the file.  The text of the files always end with the same set of characters so I had hoped to find a way to basically do something like:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="font-size: 11px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>delete from the end of $EndString to the end of the file</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>where $EndString would be the last text I want to keep and is unique in the file.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The fact that the file has binary data may make line counting hard, grep didn't seem to be able to return a line number.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Ben</DIV><DIV><BR class="khtml-block-placeholder"></DIV></BODY></HTML>