🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #9

Re: Need script to find root of filename

#9
From: Guy Harel
Date: Wed, 28 Oct 1992 13:45
18 lines
1036 bytes
ernie@PROBLEM_WITH_INEWS_GATEWAY_FILE (ackermann.cpsc) 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:


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


--
 Guy Harel 	[ guy@mai.hydro.qc.ca ]
Technical Details
Message-ID: <guy.720279933@tdsb-s>
Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!newsflash.concordia.ca!hobbit.ireq.hydro.qc.ca!guy
References: <1992Oct20.153302.2313@vixvax.mgi.com> <1c25piINNqg2@s850.mwc.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.shell
Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!newsflash.concordia.ca!hobbit.ireq.hydro.qc.ca!guy
From: guy@mais.hydro.qc.ca (Guy Harel)
Subject: Re: Need script to find root of filename
Message-ID: <guy.720279933@tdsb-s>
Sender: news@ireq.hydro.qc.ca (Netnews Admin)
Organization: Hydro-Quebec (DSB)
References: <1992Oct20.153302.2313@vixvax.mgi.com> <1c25piINNqg2@s850.mwc.edu>
Date: Wed, 28 Oct 1992 13:45:33 GMT
Lines: 18