linux 中 find命令查找输出文件的绝对路径

 

001、

[root@pc1 test1]# ls           ## 测试文件
a.txt  a.TXT  c.csv  c.tXt  d.txt  e.Txt  f.csv  k.map
[root@pc1 test1]# find ./ -name "*.txt"      ## 显示相对路径
./a.txt
./d.txt
[root@pc1 test1]# find $PWD -name "*.txt"    ## 输出绝对路径
/home/test1/a.txt
/home/test1/d.txt
[root@pc1 test1]# find $(pwd) -name "*.txt"   ## 输出绝对路径
/home/test1/a.txt
/home/test1/d.txt
[root@pc1 test1]# pwd
/home/test1
[root@pc1 test1]# find /home/test1 -name "*.txt"    ## 输出绝对路径
/home/test1/a.txt
/home/test1/d.txt

 

02、

[root@pc1 test1]# ls        ## 测试文件
a.txt  a.TXT  c.csv  c.tXt  d.txt  e.Txt  f.csv  k.map
[root@pc1 test1]# find ./ -name "*.txt"           ## 一般查找
./a.txt
./d.txt
[root@pc1 test1]# find ./ -name "*.txt" -exec readlink -f {} \;    ## 输出绝对路径
/home/test1/a.txt
/home/test1/d.txt
[root@pc1 test1]# find ./ -name "*.txt" | xargs readlink -f        ## 输出绝对路径
/home/test1/a.txt
/home/test1/d.txt
[root@pc1 test1]# find ./ -name "*.txt" -exec realpath {} \;
/home/test1/a.txt
/home/test1/d.txt
[root@pc1 test1]# find ./ -name "*.txt" | xargs realpath
/home/test1/a.txt
/home/test1/d.txt

 。

 

posted @ 2023-09-15 11:58  小鲨鱼2018  阅读(970)  评论(0编辑  收藏  举报