1833326 Members
2716 Online
110051 Solutions
New Discussion

Printer option

 
SOLVED
Go to solution
j773303
Super Advisor

Printer option

How to print one line 50 column if original file one line is 80 characters.
Hero
5 REPLIES 5
Robert-Jan Goossens
Honored Contributor
Solution

Re: Printer option

Hi,

Not sure if this would work for your printer, but you can try.

# lp -d printername -olm1 -orm50 filename

or you could try using the fold command,

# fold -w 50 filename | lp -d printername

Hope it helps,

Robert-Jan.
j773303
Super Advisor

Re: Printer option

Hi,
lp -d printername -olm1 -orm50 filename

will not print the 51 to end of line, I hope one line only include 50 characters, but 51-end of line will print to next line!! How to do it? Thanks.
Hero
Robert-Jan Goossens
Honored Contributor

Re: Printer option

Hi,

Check fold man page.

-s Break the line on the last blank character found before the specified number of column positions.If none are found, break the line at the specified
line length.

-w width Specify the maximum line length, in column
width positions. Default is 80. width should be a multiple of 8 if tabs are present, or the tabs should be expanded using expand before processing by fold (see expand(1)). The -width option is obsolescent and may be removed in a future release.

Robert-Jan.

Francisco J. Soler
Honored Contributor

Re: Printer option

Hi, I don't understand very well what you want, but if you need all the line to be printed the fold command do the trick, if you don't want all the line information and the fold command is not agree with you, you could try

cut -c1-50 file | lp

Frank
Linux?. Yes, of course.
Bill Hassell
Honored Contributor

Re: Printer option

fold simply splits long lines into a maximum of what you specify. If you want the line to be split with whole words (no split words), then use adjust:

adjust -m50 file_name | lp -dwhatever

If however, you want to truncate anything beyond 50 characters, just use cut:

cut -c 1-50 file_name | lp -dwhatever

or the shorthand for the first 50 lines: cut -c -50


Bill Hassell, sysadmin