How to find files from symbolic links with regular expression?

Viewed 232

My goal is to find certain files matching a certain regular expression. I'm using find command to achieve this goal. On a debian system the below command works perfectly.

find / -regextype 'posix-extended' -regex '^/etc/i.+/R.+'

The output is:

/etc/iproute2/rt_tables.d/README
/etc/iproute2/rt_protos.d/README
/etc/init.d/README

However, when I try the same command with a rhel system, the command outputs nothing. I know for a fact that /etc/init.d/README file is still there but regex cannot match it. I think it may be due to init.d directory being a symbolic link in rhel.

ls -l /etc/init.d
lrwxrwxrwx 1 root root 11 Apr  4  2018 /etc/init.d -> rc.d/init.d

I couldn't rewrite the command to resolve symlinks. When I provide -L argument to find command the command runs in an infinite loop while outputting find: File system loop detected; infinitely. Can you help me to rewrite the command? The best solution for me is to not change the regex since I don't generate this regex but I parse it from somewhere else. Thanks!

0 Answers
Related