Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/help/en/bash/cut.html
blob: a3ac59eaeb2547f24aaa5a9d3dec74f9277bef15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<link rel="STYLESHEET" href="../term_tools/main.css" type="text/css">
<title>cut MAN Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body><!-- #BeginLibraryItem "/Library/head_bash.lbi" --><div id="nav-menu">
<ul>
<li><a class="rl" href="../term_tools/index.html"><img src="../term_tools/images/ss64.gif" title="Home" alt="Home"></a></li>
<li><a class="rl" href="../term_tools/bash"><img src="../term_tools/images/bash-l.gif" title="bash" alt="bash"></a></li>
<li><!-- Search Google -->
<form action="http://www.google.com/search" method="get" style="margin:0px;padding:0px;">
<div align="right">
<input name="q" type="text" class="body" size="25">
<input class="submit" type="submit" value="Search">
<input type="hidden" name="q" value="site:ss64.com/bash/">
</div>
</form></li>
<li><a class="rr" href="syntax.html"><img src="../term_tools/images/syntax-r.gif" title="Bash Syntax"></a></li>
</ul>
</div> <!-- #EndLibraryItem --><h1> cut</h1> 
<p>Divide a file into several parts (columns)<br>
  Writes to standard output selected parts of each line of each input file, or 
standard input if no files are given or for a file name of `-'.</p>
<pre>Syntax
     cut [<i>OPTION</i>]... [<i>FILE</i>]...
</pre>
<p>In the options below, BYTE-LIST, CHARACTER-LIST, and FIELD-LIST are one or more 
numbers or ranges (two numbers separated by a dash)<br>
<br>
Bytes, characters, and fields are are numbered starting at 1 and 
separated by commas.  <br>
Incomplete ranges may be given: <span class="code">-M </span>means <span class="code">1-M</span> &nbsp;; <span class="code">&nbsp;N-</span> means <span class="code">N</span> through end of line or last field.</p>
<pre>Options

-b <i>BYTE-LIST</i>
--bytes=<i>BYTE-LIST</i>
     Print only the bytes in positions listed in <i>BYTE-LIST</i>.  Tabs and
     backspaces are treated like any other character; they take up 1
     byte.

-c <i>CHARACTER-LIST</i>
--characters=<i>CHARACTER-LIST</i>
     Print only characters in positions listed in <i>CHARACTER-LIST</i>.  The
     same as `-b' for now, but internationalization will change that.
     Tabs and backspaces are treated like any other character; they
     take up 1 character.

-f <i>FIELD-LIST</i>
--fields=<i>FIELD-LIST
</i>     Print only the fields listed in <i>FIELD-LIST</i>.  Fields are separated
     by a TAB character by default.

-d <i>INPUT_DELIM_BYTE</i>
--delimiter=<i>INPUT_DELIM_BYTE</i>
     For `-f', fields are separated in the input by the first character
     in INPUT_DELIM_BYTE (default is TAB).

-n
     Do not split multi-byte characters (no-op for now).

-s
--only-delimited
     For `-f', do not print lines that do not contain the field
     separator character.

--output-delimiter=<i>OUTPUT_DELIM_STRING</i>
     For `-f', output fields are separated by <i>OUTPUT_DELIM_STRING</i> The
     default is to use the input delimiter.</pre>
<p><b>  Example</b></p>
<p>Parse out  column 2 from a semicolon (;) delimited file:</p>
<p class="code">$ cat myfile.txt | cut -d \; -f 2 &gt; output.txt </p>
<p><i>&quot;It seemed the world was divided into good and bad people. The 
  good ones slept better... while the bad ones seemed to enjoy the waking hours 
  much more&quot; - Woody 
  Allen</i><br>
  <br>
  <b> Related</b>:<br>
  <br>
  <a href="csplit.html">csplit</a> - Split a file into context-determined pieces<br>
  <a href="fmt.html">fmt</a> - Reformat paragraph text <br>
  <a href="fold.html">fold</a> - Wrap input lines to fit in specified width<br>
  <a href="head.html">head</a> - Output the first part of file(s) <br>
  <a href="join.html">join</a> - Join lines on a common field <br>
  <a href="paste.html">paste</a> - Merge lines of files<br>
  <a href="split.html">split</a> - Split a file into fixed-size pieces<br>
  <a href="tail.html">tail</a> - Output the last part of files <br>
Equivalent Windows command: 
  <a href="../term_tools/nt/for_f.html">FOR</a> /F - Conditionally perform a command on items 
in a text file</p>
<!-- #BeginLibraryItem "/Library/foot_bash.lbi" --><p align="left"><script type="text/javascript"><!--
google_ad_client = "pub-6140977852749469";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
google_ad_channel ="1984328893";
google_color_border = "CCCCCC";
google_color_bg = "CCCCCC";
google_color_link = "000000";
google_color_text = "333333";
google_color_url = "0000FF";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br>
</p>
<div align="center"><hr size="1">
  <p id="top"><a href="#"><img src="../term_tools/images/top-4.gif" width="47" height="53" border="0" alt="Back to the Top" title="Back to the Top"></a></p>
  <p class="tagline">&copy; Copyright <a href="http://ss64.com/">SS64.com</a> 1999-2010<br>
Some rights reserved<br>
</p>
</div><!-- #EndLibraryItem --></body>
</html>