update a string variable and use in....

Hello Forun,

i have a variable searchpath="/home/shailesh/project/debug"
i want to make it like searchpath="/home/shailesh/project/debug/*.mk"

and want to use this like for finding all *.mk files in debug folder.

for f in "$searchpath" `find -type f`;
do
sed "s/$old_path/$project_path/g" "$f" > $TFILE && mv $TFILE "$f"
done

how i can go for this. pls help

BR
Shailesh

searchpath="/home/shailesh/project/debug/*.mk"
searchdir=$(dirname $searchpath)
searchspec=$(basename $searchpath)

for f in $(find $searchdir -type f -name $searchspec);
do
    sed "s/$old_path/$project_path/g" "$f" > $TFILE && mv $TFILE "$f"
done

If it matches a very large number of files you may need to replace the for loop with a while read loop.

but how to convert searchpath="/home/shailesh/project/debug" to
searchpath="/home/shailesh/project/debug/*.mk"
shailesh

I already converted it??? What do you mean?

i mean by which command you changed that variable
my variable is only
searchpath="/home/shailesh/project/debug"

i want to add /*.mk on the tail of this variable like
newvar=something operation on searchpath

and newvar is like
newvar="/home/shailesh/project/debug/*.mk"

I don't think you need to combine the pattern of the file and the path because in the find command u need to use it separate. anyway if you want add the pattern in the end of the path you can do it like this.

searchpath="/home/shailesh/project/debug"
newvar="${searchpath}/*.mk"
echo $newvar

thx. its working