【问题标题】:Find command to return absolute pathfind 命令返回绝对路径
【发布时间】:2015-10-16 15:47:05
【问题描述】:

我在 unix (csh) 上经常使用 find 命令。

结果是否可能是完整/绝对路径,并且将从我开始搜索的目录开始

例如,当从/project/Test/v0.15/test/frontend 运行命令时, 结果是:

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

但我想得到

/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

【问题讨论】:

标签: unix directory find csh absolute-path


【解决方案1】:

你应该使用命令realpath来解析路径:

find . -name "*.f" -exec realpath {} \;

【讨论】:

  • 这不是我通常采用的方法,但它是一种有趣的方法:-)
【解决方案2】:

我使用$PWD

find $PWD -name \*.f

【讨论】:

    【解决方案3】:

    尝试从$cwd搜索:

    find $cwd -name \*.f
    

    【讨论】:

    • 或者只使用完整路径,例如find /home/user/path/ -iname ...
    猜你喜欢
    • 2011-09-29
    • 1970-01-01
    • 2010-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-12
    相关资源
    最近更新 更多