Working with sed

Chris Davies chris at vision.UUCP
Sat Aug 11 00:23:41 AEST 1990


In article <27372 at unix.cis.pitt.edu> nr3m at 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 at vision.uucp     JANET: chris%vision.uucp at ukc
57 Cardigan Lane       | US: chris at vware.mn.org    OTHER: chris at 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" --------------



More information about the Comp.unix.questions mailing list