Working with sed

Jeff Beadles jeff at onion.pdx.com
Thu Aug 16 09:09:44 AEST 1990


nr3m at unix.cis.pitt.edu (Matthew A Henry) writes:

|>I'm writing a script that uses sed, 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 (/).  In other words I would like the string:
|>	/aaa/bbb/ccc/ddd/eee
|>to be changed to:
|>	/aaa/bbb/ccc/ddd

Of course it is.  (You can do 'most anything with sed :-)

Run the file thru this:

sed 's:/[^/][^/]*$::' < file1 > file2


Have fun!
	-Jeff
-- 
Jeff Beadles	jeff at onion.pdx.com



More information about the Comp.unix.questions mailing list