Find command to return absolute path
Asked Answered
A

3

11

I'm using find command a lot on unix (csh).

Is it possible that the result will be full/absolute path and will start from the directory where I'm starting the search

for example when running command from /project/Test/v0.15/test/frontend, the results are:

./core/serdes_complex/frontend/lib/lib_behave.f
./core/serdes_complex/frontend/lib/test_srd_compile.f

But i would like to get

/project/Test/v0.15/test/frontend/core/serdes_complex/frontend/lib/lib_behave.f
/project/Test/v0.15/test/frontend/core/serdes_complex/frontend/lib/test_srd_compile.f
Anuradhapura answered 26/7, 2015 at 11:32 Comment(2)
How are you using find command? I guess searching directly from / instead of your current directory would solve your problem!Wera
I think this might answer your question: unix.stackexchange.com/questions/125779/…Eductive
C
11

Try searching from $cwd:

find $cwd -name \*.f
Calcimine answered 26/7, 2015 at 11:40 Comment(1)
Or just use the full path e.g. find /home/user/path/ -iname ...Unmentionable
R
14

You should use the command realpath to resolve the path :

find . -name "*.f" -exec realpath {} \;
Rhonarhonchus answered 26/7, 2015 at 13:18 Comment(1)
This isn't the approach I'd usually take, but it's an interesting one :-)Calcimine
C
11

Try searching from $cwd:

find $cwd -name \*.f
Calcimine answered 26/7, 2015 at 11:40 Comment(1)
Or just use the full path e.g. find /home/user/path/ -iname ...Unmentionable
M
8

I got it to work using $PWD:

find $PWD -name \*.f

Modish answered 23/8, 2017 at 22:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.