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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TR or SED command to add carriage return at the end of line feed

Status
Not open for further replies.

rsasha

Technical User
Feb 20, 2003
5
CA
Hi all!

I have a bit of trouble with printing and wander how can I use TR or SED command to add carriage return at the end of line feed. I need to set this up as a pre-processing filter for all remote printers.

TIA.
Aleks
 
DATE: 6/8/95

The sed command is a very useful command for filtering text files.
It can also be incorporated into the virtual printer as a filter
using the following method.

Setup:

Create a sed filter file that does what you want. In the first case
I have created one to remove all carriage returns from a file. I
call this file /usr/local/rmcr

vi /usr/local/rmcr and add
s/^M//g


Next modify the virtual printer using lsvirprt.

lsvirprt
Select the virtual printer to add the filter
Change the f attribute to point at the filter. This is done by
assigning f a single character that points at an attribute with
the file name

f=l

Now change the fl attribute to use the filter file that was
created earlier. I like to use fl~v to use a vi interface to
edit the attribute. Inside the vi session enter the following:

Command String for the "l" Filter.
fl = /usr/bin/sed -f /home/labs/aixtra/sed.ch

'/usr/bin/sed -f /usr/local/rmcr'

save and exit the vi session and exit lsvirprt.

Now print to the queue and the files should have cr removed, etc.
 
I believe the question was how to add the carriage return:

cat input_file | sed 's/$/^M/' > output_file
 
You could also try changing the settings of your remote printer(s) so that on receipt of a LF it prints a CRLF.

Most printers support this setting.

The setting will be something like LF=CRLF.
 
If you are using a PCL printer, then change the virtual printer attribute to
ct=%&k2G
This will tell the printer to add the cr to lf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top