i'm trying to get a handy script to work nice and generically, and i'm stuck.
in the script, i want to use a sed command to change one parameter into another. I want to be able to write:
sed s/$1/$2/
but it doesn't work... i've tried every combinaion of quotes and such like, but not got anywhere. this sed command is in a variable assignment with back ticks, so using another backtick with echo stuff it up:
Code:
cd "$1"
for i in *
do
if [ -d "$i" ]
then
newdirpath=`echo "$PWD/$i" | sed s/$1/$2/ | tr ' ' '_' | tr A-Z a-z | sed s/_-_/-/`
# echo $newdirpath
# find if dir has subdirectories
for j in "$PWD/$i"/*
do
if [ -d "$j" ]
then
mkdir -p "$newdirpath"
fi
done
find "$PWD/$i" -iname '*.mp3' -fprint "$newdirpath".m3u
$0 "$i"
fi
done
cd -
so how do i make the first sed call generic???
------------------
edit
------------------
oh right, ok, that does actually work after all. My problem is that i want to include /'s in the variable, which is what causes the problem. i need / as i want to pass the script two directories eg /smb/mp3 and /clone/mp3. how can i do this??