🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #11

Re: Need script to find root of filename

#11
From: Boyd Roberts
Date: Wed, 28 Oct 1992 20:41
28 lines
1443 bytes
In article <guy.720279933@tdsb-s>, guy@mais.hydro.qc.ca (Guy Harel) writes:
> 
> >carpenter@vixvax.mgi.com wrote:
> >> I have a directory containing filenames of the form "*.[0-9]*",
> >> and would like to write a csh script to print out the "root" of
> >> each name.  For example, if the names abc.def.012 and gh.ijkl.mno.987
> >> appear in the directory, I would like to see abc.def and gh.ijkl.mno
> >> printed out.
> 
> I had fun trying the following:

I'm sure you did.

> 
> echo abc.def.ghi.123 |  \
> awk -F. '{ $x=$1 ; for ( i = 2 ; i < NF ; i++ ) $x=$x"."$i } END { print $x }'

Could you make it a little more complex?

    prl313 ; echo abc.def.ghi.123 | sed 's/\(.*\)\..*/\1/'
    abc.def.ghi

Nah, too simple.


Boyd Roberts			boyd@prl.dec.com

``When the going gets wierd, the weird turn pro...''
Technical Details
Message-ID: <1992Oct28.204157.14215@prl.dec.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!usenet.coe.montana.edu!decwrl!pa.dec.com!decprl!decprl!boyd
References: <1992Oct20.153302.2313@vixvax.mgi.com> <1c25piINNqg2@s850.mwc.edu> <guy.720279933@tdsb-s>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!usenet.coe.montana.edu!decwrl!pa.dec.com!decprl!decprl!boyd
From: boyd@prl.dec.com (Boyd Roberts)
Newsgroups: comp.unix.shell
Subject: Re: Need script to find root of filename
Message-ID: <1992Oct28.204157.14215@prl.dec.com>
Date: 28 Oct 92 20:41:57 GMT
Article-I.D.: prl.1992Oct28.204157.14215
References: <1992Oct20.153302.2313@vixvax.mgi.com> <1c25piINNqg2@s850.mwc.edu> <guy.720279933@tdsb-s>
Sender: news@prl.dec.com (USENET News System)
Organization: Digital Equipment Corporation - Paris Research Laboratory
Lines: 28
Nntp-Posting-Host: prl313.prl.dec.com