bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: have cut -c print output-delimiter


From: Jan Nieuwenhuizen
Subject: Re: have cut -c print output-delimiter
Date: Sun, 19 Jan 2003 22:19:52 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu)

Jim Meyering <address@hidden> writes:

> The only part remaining is to update the texinfo documentation
> with a description of the new feature.  Would you like to do that,
> including the nice example you gave above?

Here's a little something.  Funny how looking for fixed-width data
brings you to all sorts of sites you usually don't want to visit.

Sorry it took so long, it's been a rather busy week.

Greetings,
Jan.

--- coreutils.texi.orig 2003-01-19 18:26:51.000000000 +0100
+++ coreutils.texi      2003-01-19 22:14:58.000000000 +0100
@@ -11790,8 +11790,46 @@
 @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:
+
address@hidden Is using cal ok?  Looked at gcal, but I don't like it.
address@hidden
+$ cal | cut -c 3-5
address@hidden
address@hidden    
address@hidden  6
address@hidden 13
address@hidden 20
address@hidden 27
address@hidden example
+
+Cut can also add field separators to fixed width data, using the
address@hidden option.  This can be very useful to fill a
+database:
+
address@hidden [Why] can't that silly total line for directories be switched 
off?
address@hidden
+$ ls -ld ~/* | cut --output-delimiter=, -c1,2-4,5-7,8-10,57- | tee home.cs
address@hidden d,rwx,r-x,r-x,CVS
address@hidden d,rwx,---,---,Mail
address@hidden d,rwx,r-x,r-x,lilypond
address@hidden 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
address@hidden test.home: Records: 4  Deleted: 0  Skipped: 0  Warnings: 0
+$ mysql -e 'select * from home' test
address@hidden +------+------+------+------+---------------------+
address@hidden | d    | u    | g    | o    | name                |
address@hidden +------+------+------+------+---------------------+
address@hidden | d    | rwx  | r-x  | r-x  | /home/fred/CVS      |
address@hidden | d    | rwx  | ---  | ---  | /home/fred/Mail     |
address@hidden | d    | rwx  | r-x  | r-x  | /home/fred/lilypond |
address@hidden | d    | rwx  | r-x  | r-x  | /home/fred/savannah |
address@hidden +------+------+------+------+---------------------+
address@hidden example
 
 
 @node The sort command


-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien       | http://www.lilypond.org





reply via email to

[Prev in Thread] Current Thread [Next in Thread]