如何使用shell查找某个文件的完整路径?

时间:2016-11-04 08:07:39

标签: linux shell

我遇到了问题,在我的Ubuntu中,我在/local/jenkins/scripts这样的目录中工作,这里有很多子目录,我想在目录中获取所有的excute.sh文件,但是你可能知道,如果我使用" find -name excute.sh",它将返回相对路径列表,如下所示。

./TEST933/excute.sh
./TEST923/excute.sh
./TEST323/excute.sh
./TEST920/excute.sh

您能否分享如何获取完整路径列表如下?谢谢!

/local/jenkins/scripts/TEST933/excute.sh
/local/jenkins/scripts/TEST923/excute.sh
/local/jenkins/scripts/TEST323/excute.sh
/local/jenkins/scripts/TEST920/excute.sh

2 个答案:

答案 0 :(得分:1)

你可以用这个;

find /local/jenkins/scripts/ -name excute.sh

例如

$ find -name excute.sh
./TEST920/excute.sh
./TEST933/excute.sh
./TEST923/excute.sh
./TEST323/excute.sh

$ find /tmp/test/ -name excute.sh
/tmp/test/TEST920/excute.sh
/tmp/test/TEST933/excute.sh
/tmp/test/TEST923/excute.sh
/tmp/test/TEST323/excute.sh

答案 1 :(得分:1)

带有readlink;

find -name excute.sh -exec readlink -f {} \;
相关问题