For faster navigation, this Iframe is preloading the Wikiwand page for cut (Unix).

cut (Unix)

在电脑使用上,cut是一种Unix命令行程序。它常用来截取每行输入──通常是文件──的片段。

一般截取行片段可以透过位元-b)、字符、或者以分隔字符(-d—默认为跳位字符)分隔的字段(-f)达成。每次做截取都必须给定范围,包括下面四种之一:N, N-M, N-N到行尾),或者-M(行头到M)。

示例

[编辑]

假设一个文件名叫 file 包含下面数行:

foo:bar:baz:qux:quux
one:two:three:four:five:six:seven
alpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu

输出每行第四到第十字符就是:

% cut -c 4-10 file

输出结果:

:bar:ba
:two:th
ha:beta

使用冒号当字段分隔字符输出第五栏到每行行尾:

% cut -d : -f 5- file

输出结果:

quux
five:six:seven
epsilon:zeta:eta:teta:iota:kappa:lambda:mu

参见

[编辑]

外部链接

[编辑]
{{bottomLinkPreText}} {{bottomLinkText}}
cut (Unix)
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?