I have a directory A with a bunch of files with .xml extension that I need to run a search-and-replace on. There are a couple of symlinks (also with .xml extension) in A that link to certain files in A. I tried running sed -i 's/search_regexp/replacement_string/' *.xml but when it hits a symlink it fails with
sed: ck_follow_symlink: couldn't lstat file.xml: No such file or directory
A solution would be to loop around the files that I actually want to modify and call sed on each file, but is there a way to tell sed to ignore symlinks? or just follow them and modify the linked file?
@piokuc already named the option for following symlinks, here’s how you can ignore them with
findfirst:or, slightly more efficient:
The
! -type lpart means “not anything that is a symlink”