Linux lp命令(-o选项,-d目标打印机,-p页码范围)

发布时间 2023-10-27 22:34:58作者: 阳光依旧是我

 

原文主要介绍lp命令的参数和描述。常见命令包括:

lp filename(打印filename)

-d 打印机名称(指定打印机)

-P 1,2-5,6 (指定页码范围)

-o sides=two-sided-long-edge(选项,长边翻转,竖直打印)

-o number-up (指定一页几版)

……有趣的打印命令详见下文

lp命令原文:通过命令行,man lp得到:

NAME
lp - print files

SYNOPSIS 大纲;概要;梗概
lp
[ -E ]
[ -U username ]
[ -c ]
[ -d destination[/instance] ]
[ -h hostname[:port] ]
[ -m ] [ -n num-copies ]
[ -o option[=value] ]
[ -q priority ]
[ -s ]
[ -t title ]
[ -H handling ]
[ -P page-list ]
[ -- ]
[ file(s) ]

lp
[ -E ]
[ -U username ]
[ -c ]
[ -h hostname[:port] ]
[ -i job-id ]
[ -n num-copies ]
[ -o option[=value] ]
[ -q priority ]
[ -t title ]
[ -H handling ]
[ -P page-list ]

DESCRIPTION 描述;产品描述;说明;品名;产品说明
lp submits files for printing or alters a pending job.
提交要打印的文件或更改挂起的作业
Use a filename of "-" to force printing from the standard input.
使用文件名“-”强制从标准输入进行打印。

THE DEFAULT DESTINATION
默认目的地(默认打印机)

CUPS provides many ways to set the default destination.
提供了许多设置默认目标的方法。
The LPDEST and PRINTER environment variables are consulted first. If neither are set,
the current default set using the lpoptions(1) command is used, fol‐
lowed by the default set using the lpadmin(8) command.
OPTIONS 选项
The following options are recognized by lp:

-- Marks the end of options; use this to print a file whose name
begins with a dash (-).

-E Forces encryption when connecting to the server.

-U username
Specifies the username to use when connecting to the server.

-c This option is provided for backwards-compatibility only. On sys‐
tems that support it, this option forces the print file to be
copied to the spool directory before printing. In CUPS, print
files are always sent to the scheduler via IPP which has the same
effect.

-d destination
Prints files to the named printer.
将文件打印到指定的打印机
-h hostname[:port]
Chooses an alternate server.
选择备用服务器。
-i job-id
Specifies an existing job to modify.

-m Sends an email when the job is completed.

-n copies
Sets the number of copies to print.
设置要打印的份数
-o "name=value [ ... name=value ]"
Sets one or more job options. See "COMMON JOB OPTIONS" below.
设置一个或多个作业选项。请参阅下面的“常见工作选项”。
-q priority
Sets the job priority from 1 (lowest) to 100 (highest). The
default priority is 50.
将作业优先级从1(最低)设置为100(最高)。这个默认优先级为50。

-s Do not report the resulting job IDs (silent mode.)
不报告生成的作业ID(静默模式)
-t "name"
Sets the job name.
设置作业名称

-H hh:mm

-H hold

-H immediate

-H restart

-H resume
Specifies when the job should be printed. A value of immediate
will print the file immediately, a value of hold will hold the job
indefinitely, and a UTC time value (HH:MM) will hold the job until
the specified UTC (not local) time. Use a value of resume with
the -i option to resume a held job. Use a value of restart with
the -i option to restart a completed job.
指定打印作业的时间。值immediate将立即打印文件,
值hold将无限期保留作业,而UTC时间值(HH:MM)将保留作业直到指定的UTC
(非本地)时间。将resume的值与-i选项一起使用可恢复保留的工作。将值
restart与-i选项一起使用可重新启动已完成的作业。
-P page-list
Specifies which pages to print in the document. The list can con‐
tain a list of numbers and ranges (#-#) separated by commas, e.g.,
"1,3-5,16". The page numbers refer to the output pages and not
the document's original pages - options like "number-up" can
affect the numbering of the pages.
指定要在文档中打印的页面。列表可以包含数字和范围的列表(#-#),用逗
号分隔,例如“1,3-5,16”。页码指的是输出页面,而不是文档的原始页面,
“编号向上”之类的选项会影响页面的编号。

COMMON JOB OPTIONS 常见作业选项

Aside from the printer-specific options reported by the lpoptions(1)
command, the following generic options are available:
除了lpoptions(1)命令报告的打印机特定选项外,还提供以下通用选项:

-o collate=true
Prints collated copies.
打印已校对的副本

-o fit-to-page
Scales the print file to fit on the page.
缩放打印文件以适合页面。


-o job-hold-until=when
Holds the job until the specified local time. "when" can be
"indefinite" to hold the until released, "day-time" to print the
job between 6am and 6pm local time, "night" to print the job
between 6pm and 6am local time, "second-shift" to print the job
between 4pm and 12am local time, "third-shift" to print the job
between 12am and 8am local time, or "weekend" to print the job on
Saturday or Sunday.
将作业保留到指定的本地时间。“当“可”无限期“持有直到发布,”白天时间“
打印作业在当地时间早上6点到晚上6点之间,“晚上”打印作业在当地时间下
午6点到早上6点之间,“第二班”打印作业在当地时间下午4点到12点之间,
“第三班”打印作业在当地时间上午12点到8点之间,或“周末”在周六或周日
打印作业。


-o job-hold-until=hh:mm
Holds the job until the specified time in hours and minutes UTC.
将作业保留到指定的时间(UTC小时和分钟)。

-o job-priority=priority
Set the priority to a value from 1 (lowest) to 100 (highest),
which influences when a job is scheduled for printing. The
default priority is typically 50.
将优先级设置为1(最低)到100(最高)之间的值,这会影响计划打印作业的时间。
默认优先级通常为50。


-o job-sheets=name
Prints a cover page (banner) with the document. The "name" can be
"classified", "confidential", "secret", "standard", "topsecret",
or "unclassified".
打印包含文档的封面(横幅)。“名称”可以是“机密”、“机密”、“机密”、
“标准”、“绝密”或“非机密”。


-o job-sheets=start-name,end-name
Prints cover pages (banners) with the document.
打印带有文档的封面(横幅)。

-o media=size
Sets the page size to size. Most printers support at least the
size names "a4", "letter", and "legal".
将页面大小设置为“大小”。大多数打印机至少支持大小名称“a4”、“letter”和“legal”。


-o mirror
Mirrors each page.
镜像每页


-o number-up={2|4|6|9|16}
Prints 2, 4, 6, 9, or 16 document (input) pages on each output
page.
在每个输出页上打印2、4、6、9或16个文档(输入)页。

-o number-up-layout=layout
Specifies the layout of pages with the "number-up" option. The
"layout" string can be "btlr", "btrl", "lrbt", "lrtb", "rlbt",
"rltb", "tblr", or "tbrl" - the first two letters determine the
column order while the second two letters determine the row order.
"bt" is bottom-to-top, "lr" is left-to-right, "rl" is right-to-
left, and "tb" is top-to-bottom.
使用“数字向上”选项指定页面的布局。“layout”字符串可以是“btlr”、“btrl”
、“lrbt”、“lrtb”、“rlbt”、“rltb”、“tblr”或“tbrl”-前两个字母确定列顺序
,后两个字母确定行顺序bt是从下到上,“lr”是从左到右,“rl”是从右到左,
“tb”是从上到下。
-o orientation-requested=4
Prints the job in landscape (rotated 90 degrees counter-clock‐
wise).
横向打印作业(逆时针旋转90度)。


-o orientation-requested=5
Prints the job in landscape (rotated 90 degrees clockwise).
横向打印作业(顺时针旋转90度)。


-o orientation-requested=6
Prints the job in reverse portrait (rotated 180 degrees).
以反向纵向打印作业(旋转180度)。
-o outputorder=reverse
Prints pages in reverse order.
按相反顺序打印页面。


-o page-border=border
Prints a border around each document page. "border" is "double",
"double-thick", "single", or "single-thick".
在每个文档页周围打印边框。““边框”是“双层”、“双层厚”、“单层”或“单层厚”。
-o page-ranges=page-list
Specifies which pages to print in the document. The list can con‐
tain a list of numbers and ranges (#-#) separated by commas, e.g.,
"1,3-5,16". The page numbers refer to the output pages and not
the document's original pages - options like "number-up" can
affect the numbering of the pages.
指定要在文档中打印的页面。列表可以包含数字和范围的列表(#-#),用逗
号分隔,例如“1,3-5,16”。页码指的是输出页面,而不是文档的原始页面选项
(如“向上编号”)可能会影响页面的编号。

-o sides=one-sided
Prints on one side of the paper.
在纸的一面打印。


-o sides=two-sided-long-edge
Prints on both sides of the paper for portrait output.
在纸张的两面打印,以便输出肖像。


-o sides=two-sided-short-edge
Prints on both sides of the paper for landscape output.
打印在纸张的两面,用于横向输出。


CONFORMING TO 遵循
Unlike the System V printing system, CUPS allows printer names to con‐
tain any printable character except SPACE, TAB, "/", or "#". Also,
printer and class names are not case-sensitive.
与System V打印系统不同,CUPS允许打印机名称包含除空格、制表符、“/”或“#”
以外的任何可打印字符。此外,打印机和类名不区分大小写。
The -q option accepts a different range of values than the Solaris lp
command, matching the IPP job priority values (1-100, 100 is highest
priority) instead of the Solaris values (0-39, 0 is highest priority).
q选项接受的值范围与Solaris lp命令不同,它匹配的是IPP作业优先级值
(1-100100是最高优先级),而不是Solaris值(0-39,0是最高优先级)。


EXAMPLES 示例

Print two copies of a document to the default printer:
将文档的两个副本打印到默认打印机:
lp -n 2 filename

Print a double-sided legal document to a printer called "foo":
将双面法律文件打印到名为“foo”的打印机上:
lp -d foo -o media=legal -o sides=two-sided-long-edge filename

Print a presentation document 2-up to a printer called "foo":
将演示文档2-up打印到名为“foo”的打印机上:
lp -d foo -o number-up=2 filename

SEE ALSO 另请参见

cancel(1), lpadmin(8), lpoptions(1), lpq(1), lpr(1), lprm(1),
lpstat(1), CUPS Online Help (http://localhost:631/help)