Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trim FF near beginning of file.

Status
Not open for further replies.

motoslide

MIS
Oct 30, 2002
764
US
I need to strip leading FormFeed characters from files as they are printed. Unfortunately, there are PCL commands at the beginning of the file which must be preserved. Also, other FormFeeds throughout the file should be preserved.
So, the task is to find and eliminate FF (ASCII 0c) only if it occurs within the first 80(?) characters.

To illustrate, consider this HexDump of a report:
Code:
0000    0d 1b 26 6c 30 6f 32 61  36 44 1b 28 31 30 55 1b   ..&l0o2a6D.(10U.
0010    28 73 70 31 30 68 31 32  76 73 62 33 54 0d 0c 31   (sp10h12vsb3T..1
0020    30 2f 31 37 2f 30 35 20  20 20 20 20 20 20 20 20   0/17/05
I need to eliminate that "0c" at character position 31. The exact position will vary. Can I use sed to change the first instance of 0d0c to 0d only? This needs to be invoked within the printer interface script, so the source would be STDIN, and the output would be STDOUT.

 
Personally I would use perl to do this.
I would have a script that did a "read" of 80 bytes and do a regex to remove only 1 "0c" char.
Then I'd just echo out the rest of the file.
Do you need me to write it for you?


Trojan.
 
Thanks for the offer, but most of our Clients' systems don't have perl.
I was able to accomplish my goal by changing the following line in the printer interface file:

Old
cat "$file" 2>&1
New:
cat "$file" | sed '1,2 s/^L//' 2>&1

It's not perfect, but should work for the majority of our reports.
 
the unix tr (translate) function can also be used to remove or replace.

-------------------------
The trouble with doing something right the first time is that nobody appreciates how difficult it was - Steven Wright
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top