Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!mcsun!ukc!axion!vision!chris From: chris@vision.UUCP (Chris Davies) Newsgroups: comp.unix.questions Subject: Re: Working with sed Message-ID: <1157@vision.UUCP> Date: 10 Aug 90 14:23:41 GMT References: <994@netmbx.UUCP> <13513@smoke.BRL.MIL> <27372@unix.cis.pitt.edu> Reply-To: chris@vision.UUCP (Chris Davies) Organization: VisionWare Ltd., Leeds, UK Lines: 34 In article <27372@unix.cis.pitt.edu> nr3m@unix.cis.pitt.edu (Matthew A Henry) writes: >I'm writing a script that uses sed, I'm assuming by this that you don't mean 'working with a sed script'. >and am having trouble with one >part. I have a file that contains typical unix paths, one per >line, and would like to remove everything after the last forward >slash (/). Why use sed? You've said you're using a script with sed in it, so why not use something different. On SysV and SunOS 4.0.3_EXPORT (therefore probably BSD systems in general??) you can use _d_i_r_n_a_m_e to do exactly what you require. >In other words I would like the string: > /aaa/bbb/ccc/ddd/eee >to be changed to: > /aaa/bbb/ccc/ddd Check out _b_a_s_e_n_a_m_e too. Thus, % dirname '/aaa/bbb/ccc/ddd/eee' /aaa/bbb/ccc/ddd/eee % basename '/aaa/bbb/ccc/ddd/eee' eee % Chris -- VISIONWARE LTD | UK: chris@vision.uucp JANET: chris%vision.uucp@ukc 57 Cardigan Lane | US: chris@vware.mn.org OTHER: chris@vision.co.uk LEEDS LS4 2LE | BANGNET: ...{backbone}!ukc!vision!chris England | VOICE: +44 532 788858 FAX: +44 532 304676 -------------- "VisionWare: The home of DOS/UNIX/X integration" --------------