Need help with sed statement

David Bartmess dingodave at edingo.net
Tue May 4 03:37:15 UTC 2010


Not sure if this is the right place, but I need help with a sed 
replacement expression.

I'm trying to express only the filename from a filepath, i.e., 
whoopie.txt from /opt/dev/whoopie.txt.

Basically I'm reading the files that changed into a temp file, and 
reading each line into a variable to split out the base filename to act 
upon.

I tried using the following, but it still gives me the entire string:

#!/bin/bash
BASEDIR="/opt/dev";
echo $BASEDIR | sed "s/$BASEDIR\///"

This gives me back the entire original string.

And I also tried the following sed statement:

echo $BASEDIR |  sed "s/^.*\([^/]+\)$/\1/"
This gives me back nothing at all

Thanks for any help!

-- 
"Dingo" Dave Bartmess
Broomfield, CO. USA
http://edingo.net




More information about the users mailing list