Share on Facebook Share on Twitter Email
Answers.com

Cut

 
Wikipedia: Cut (Unix)

In computing, cut is a Unix command line utility which is used to extract sections from each line of input — usually from a file.

Extraction of line segments can typically be done by bytes (-b), characters (-c), or fields (-f) separated by a delimiter (-d — the tab character by default). A range must be provided in each case which consists of one of N, N-M, N- (N to the end of the line), or -M (beginning of the line to M), where N and M are counted from 1 (there is no zeroth value). Since version 6, an error is thrown if you include a zeroth value. Prior to this the value was ignored and assumed to be 1.

Examples

Assuming a file named file containing the lines:

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

To output the fourth through tenth characters of each line:

% cut -c 4-10 file

This gives the output:

:bar:ba
:two:th
ha:beta

To output the fifth field through the end of the line of each line using the colon character as the field delimiter:

% cut -d : -f 5- file

This gives the output:

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

See also

External links


Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
 
 
Learn More
Dissection (in medicine)
Laceration (in medicine)
cut (Idiom)

How do you get a cut? Read answer...
What does cut do? Read answer...
What do you do to a cut? Read answer...

Help us answer these
Where to get cut?
What is to cut out?
How do you cut cold cuts?

Post a question - any question - to the WikiAnswers community:

 

Copyrights:

Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Cut (Unix)" Read more