Re: stupid shell tricks again

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Craig White
Date:  
To: plug-discuss
Subject: Re: stupid shell tricks again
On Mon, 2004-03-22 at 20:50, ec wrote:
> --- Craig White <> wrote:
> > On Mon, 2004-03-22 at 17:45, Bill Jonas wrote:
> > > On Mon, Mar 22, 2004 at 05:29:35PM -0700, Craig
> > White wrote:
> > > > I will be dammed but I can't make the line above
> > this one work...this is
> > > > where the problem is...
> > > > i=`echo $line | cut -f1`;
> > >
> > > Try:
> > > i=`echo $line | cut -d' ' -f1`;
> > > instead.
> > ----
> > yup that did it
> >
> > this is too hard for me ;-)
> >
> > Craig
> > \
>
> The part... -d' ' -f1 set the delimiter to the first
> field.. per my unix1 class just a couple hours ago!
> The space between the two ' ' sets the delimiter to
> the space bar or white space in the output of $line
> (if I understood Gerald, my instructor correctly.
>
> Excerpt from the 'class' Here, we needed the
> ':' or colon delimiter, but you need the ' ' white
> space delimiter
>
> $ cut -f1 -d":" /etc/passwd | and on to another stdin
>
>
>       The 'cut' command prints the values of field
>       one found in the /etc/passwd file having colon
>       delimited fields. 

>
> He wrote one in the class as an example and used the
> white space delimiter.
>
> Hope that explains that/helped!!!

----
actually, man cut told me that in the beginning. It also says that the
default is a tab and it was a tab that separated the two fields. In
fact, in the first version, the cut -f1 worked perfectly without any
specific reference to the delimiter. Apparently, the result of the
command that 'echo string' | cut somehow modifies the tab where it isn't
identified as a tab - that was sort of clear when Bill Jonas made the
delimiter suggestion and it worked.

Had the delimiter been something as obvious as the colon or vertical
bar, I would have been all over it. It clearly was an invisible tab
character (Control-I) inside of the string output by the du command but
apparently converted invisibly to a space (or white space) when it was
echo'd and piped to the cut command. It was a gremlin from Redmond.

Craig

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss