On Tue, 2002-09-24 at 12:24, Peter Leftwich wrote:
> On Mon, 23 Sep 2002, Giorgos Keramidas wrote:
> > On 2002-09-22 21:53, Peter Leftwich <[EMAIL PROTECTED]> wrote:
> > > That leads me to wonder about using "rev" to reverse the order of
> > > characters on the line and "cut" using a field delimiter of "."  :)  :)
> > You probably could, and then use rev to fix the lines back to their
> > normal form too. `rev | cut -d. -f2- | rev`
> 
> I definitely favor "cut."  How common across the various Unices/Unixes is
> cut, that is, does Sun/Solaris or Linux come with cut included?

It's been on every box I've tried to use it on - SunOS, Solaris, Digital
UNIX, AIX, FreeBSD, Linux ...

> 
> > You can do that with sed(1) too, though: `sed -e 's/\.[^.]*$//'`
> 
> Can you say in poor-man's terms what the above line does?  I used to use
> `sed -e 's/this/that/g'` often but haven't for a few years now.  The way I
> would remember the command was "sed edit substitute this for that _g_ood
> we're done" even though I am aware the g is for global.

`sed -e 's/\.[^.]*$//'`

That says match a literal period followed by zero or more non-period
characters up to the end of the line, and delete them.

Or to put it another way, chop the file extension off - if it was
something like 'foo.tar.gz' it would become 'foo.tar' and not 'foo'

> 
> > Both of these should strip the `.xxx' extension of all input lines.
> > Then, there's Perl, awk, and a few other tools.  Practically unlimited
> > ways of doing the same thing :)
> > Giorgos.
> 
> I wonder if there is a book just chock full of sed, awk, cut, and perl
> examples dissected into layman's terms... :)  Maybe an ORA.COM book?

ORA has several books :-)

A book called 'sed and awk' which I've never really read too much of
since I discovered Perl just after purchasing it. There are several Perl
books - if you want examples, I would suggest trying "The Perl
Cookbook."

You might also want to pick up a copy of "Mastering Regular
Expressions."

As far as the use of cut goes, it doesn't really warrant a book of its
own (it doesn't do much beyond what the man page says), but you may find
it used in various scripts around the place


Regards,
Duncan Anker


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message

Reply via email to