Hi all,
My directory structure is as follows
home /md/DEV/SCRIPTS/DAILY and home/md/DEV/MIS/LANDING

so this command
find home/md/DEV/MIS/LANDING -name MIS_Customer_\*
is giving me the desired output
/home/md/DEV/MIS/LANDING/MIS_Customer_20080114.txt.
since i dont want to hardcode the path ie)home/md/DEV i opt for relative path like
find ../../MIS/LANDING -name MIS_Customer_\*.(since all myall my scripts are in SCRIPTS/DAILY).because of this, am getting output
as
../../CIS/LANDING/MIS_Customer_20080114.txt which is undesirable.instead i want it like /home/md/DEV/MIS/LANDING/MIS_Customer_20080114.txt...pease help me to do this.or let me know if there is anyother workaround

regards,
rajarp

You can do find $PWD/../../MIS/LANDING -name MIS_Customer_\* which will get you paths beginning with /, but you'll still have the ../ relative path movements in the middle.

There is another command called 'realpath' which resolves all relative paths and symbolic links to give you a canonical path.

You can do find $PWD/../../MIS/LANDING -name MIS_Customer_\* which will get you paths beginning with /, but you'll still have the ../ relative path movements in the middle.

There is another command called 'realpath' which resolves all relative paths and symbolic links to give you a canonical path.

thanks salem,
thanks for your help.but it dint solved my problem as you said.Now am gettin my ouput as /home/md/DEV/SCRIPTS/DAILY/../../MIS/LANDING/CMS_Customer_20080114.txt ,which wont work as far as my requirement is concerned.is there anyother way to achive this...???
please let me know.

Regards,
Rajarp

I agree - aside from realpath and other provided solutions in C and perl, I think you can't do it very easily.

Perhaps (but this would still be restrictive)

find ../../MIS/LANDING -name MIS_Customer_\*|sed 's/\.\.\/\.\.\//\/home\/md\/DEV\//'

since it requires forknowledge of the directory your absolute path goes to.

I'd be interested in seeing this solved :)

Best wishes,

,Mike

DIR=`(cd ../../MIS/LANDING;pwd)`
find ${DIR} -name MIS_Customer_\*
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.