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!

PCL Code & csplit

Status
Not open for further replies.

thepom02

Programmer
Dec 13, 2002
9
US
I have a file which contains PCL codes as well as other text records. Its basically a file with formatted letters. I have written a script which takes some id's as input and strips off the letters for those ids using csplit within a loop. The script works fine except the lines with PCL codes are not copied over. Does anyone know why this is the case.

 
Perhaps because the PCL escape sequences are binary strings confusing csplit.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
csplit only works with text, so it won't be the tool to use.

Could you be more specific about what needs to be done?

Are you wanting to remove the letters that match the ids from the larger print job? or to reduce the print job to only those letters?

Is the PCL code scattered through the file, or is there a single block of it at the beginning?

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Basically what I have is a large file containing the letters. On the first line of each letter (along with some other information) is a unique id. What I want the script to do is to be able to accept as input a list of id's and copy the full letter for those ids to a new file to be later printed. The PCL codes are scattered throughout each letter (they set proportional font, fixed font, italics etc.)

The script I created works exactly as I want it except the lines with PCL codes are not copied. I now know these are confusing csplit.

thanks for your help
 
Have you tried to play with sed or awk ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
perl would also be an option.

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
How would I accomplish this with sed or awk. I can see how I could match the first line by the unique ID but then how would I make the script print the rest of the letter.

Basically I need to do the following:

Identify the first line of letter (this will contain the id)
Print this line to output file.
Print all subsequent lines until a new letter first line is found. (I can identify this by a literal).

thanks
 
Code:
awk '
/patternmatchingid/{inletter++}
/patternmatchingfirstofnextletter/{exit}
(inletter)
' inputfile.pcl

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Thanks for the input to date but awk has the same results as the csplit. It will not recognise the lines with the PCL codes.

For example if I do awk '{print $0}' input.file

then anything following the PCL codes (including the codes) are not printed.

I need to play with either grep or sed as they will recognise the PCL lines.
 
try this, to make sure the codes aren't there:

awk '{print $0}' input.file | cat -ev

The PCL codes are often seen as meaningless escape sequences by terminal software, and some are followed by carriage return, causing overtype.

Both GNU Awk 3.1.1 and the version of awk on AIX 4.3.3 handle PCL codes just fine.


Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top