Bash发现不包括路径?

时间:2013-11-14 00:13:57

标签: bash find

就像标题所说的那样,

domain='foo.com'

find . -iregex '.*\(html\|htm\)' -printf '%f\0' | \
xargs -0 sed -Ee "s:(http|https)\://(www.|)${domain}::g" 

# sed: can't read index.html: No such file or directory

我期待

directory/directory/index.html

不确定发现了什么?

2 个答案:

答案 0 :(得分:1)

manual page说:

%f     File's name with any leading  directories  removed  (only
       the last element).

答案 1 :(得分:0)

使用“%h%f”获取完整路径(相对于当前路径)。

find . -iregex '.*\(html\|htm\)' -printf '%h%f\0'