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

Re: [OT] Text stream editing problem



on Mon, Sep 08, 2003 at 12:33:39AM +0800, csj (csj@zapo.net) wrote:
> Let's say I want to write a script that can convert the
> following:
> 
> A-0001     Directory_1/Subdirectory_1/File_1.txt
> A-0002     ./Directory_2/Subdirectory_2/File_2.txt
> A-0003     ./Directory_3/Subdirectory_3/Subdirectory_4/File_3.txt
> 
> to:
> 
> A-0001     /Subdirectory_1/File_1.txt
> A-0002     /Subdirectory_2/File_2.txt
> A-0003     /Subdirectory_3/Subdirectory_4/File_3.txt
> 
> My basic strategy would be to sed 's|/Directory_.||g'.
> Unfortunately this isn't of universal application.  I'm looking
> for a solution than can take into account all possible names for
> "Dir_Foo".

Based on what you've presented:

    sed -e 's/[ 	]\.*\(\/Subdirectory_\)/	\1/'

Peace.

-- 
Karsten M. Self <kmself@ix.netcom.com>        http://kmself.home.netcom.com/
 What Part of "Gestalt" don't you understand?
  Backgrounder on the Caldera/SCO vs. IBM and Linux dispute.
      http://sco.iwethey.org/

Attachment: pgprNqxuuYSqF.pgp
Description: PGP signature


Reply to: