ehime
ehime

Reputation: 8375

Bash find not including paths?

Just like the title says,

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

I am expecting

directory/directory/index.html

Not sure whats going on with find?

Upvotes: 0

Views: 86

Answers (2)

JackDVD
JackDVD

Reputation: 164

Use "%h%f" to get the full path (relative to the current path).

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

Upvotes: 1

Brad Lanam
Brad Lanam

Reputation: 5723

The manual page says:

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

Upvotes: 2

Related Questions