summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-01-24 13:46:28 +0000
committerJim Meyering <jim@meyering.net>2003-01-24 13:46:28 +0000
commit527715894fcbb3ccd572b13769955c65a7b43a77 (patch)
treed669864cf6ba073cb50dcc68f342d2080897629b /doc
parent37ac1f18f148571b76bcb79f374b1c925f8a641e (diff)
downloadcoreutils-527715894fcbb3ccd572b13769955c65a7b43a77.tar.xz
(The cut command): Give an example of using cut -c
with an output delimiter. From Jan Nieuwenhuizen.
Diffstat (limited to 'doc')
-rw-r--r--doc/coreutils.texi43
1 files changed, 40 insertions, 3 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 1994a2c65..657ed5b6e 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -11880,9 +11880,46 @@ $ cut -d: -f1,5 /etc/passwd
@end example
With the @option{-c} option, @command{cut} will cut out specific characters
-(i.e., columns) in the input lines. This command looks like it might be
-useful for data filtering.
-
+(i.e., columns) in the input lines. This is useful for input data
+that has fixed width fields, and does not have a field separator. For
+example, list the Monday dates for the current month:
+
+@c Is using cal ok? Looked at gcal, but I don't like it.
+@example
+$ cal | cut -c 3-5
+@print{}Mo
+@print{}
+@print{} 6
+@print{} 13
+@print{} 20
+@print{} 27
+@end example
+
+Cut can also add field separators to fixed width data, using the
+@option{--output-delimiter} option. This can be very useful to fill a
+database:
+
+@c [Why] can't that silly total line for directories be switched off?
+@example
+$ ls -ld ~/* | cut --output-delimiter=, -c1,2-4,5-7,8-10,57- | tee home.cs
+@print{} d,rwx,r-x,r-x,CVS
+@print{} d,rwx,---,---,Mail
+@print{} d,rwx,r-x,r-x,lilypond
+@print{} d,rwx,r-x,r-x,savannah
+$ mysql -e 'create table home \
+ (d char(1),u char(3), g char (3), o char (3), name text)' test
+$ mysqlimport --fields-terminated-by=, test home.cs
+@print{} test.home: Records: 4 Deleted: 0 Skipped: 0 Warnings: 0
+$ mysql -e 'select * from home' test
+@print{} +------+------+------+------+---------------------+
+@print{} | d | u | g | o | name |
+@print{} +------+------+------+------+---------------------+
+@print{} | d | rwx | r-x | r-x | /home/fred/CVS |
+@print{} | d | rwx | --- | --- | /home/fred/Mail |
+@print{} | d | rwx | r-x | r-x | /home/fred/lilypond |
+@print{} | d | rwx | r-x | r-x | /home/fred/savannah |
+@print{} +------+------+------+------+---------------------+
+@end example
@node The sort command
@unnumberedsec The @command{sort} Command