Try this :
find /home/ -type f -regextype posix-extended -regex ".*(string1|string2|$HOSTNAME).*"
if you need to use a command instead :
find /home/ -type f -regextype posix-extended -regex ".*(string1|string2|$(hostname)).*"
Question
Is there a possibility to do command substitution in a regex? I want to find files in Linux with specific names. The name may include fix strings, but it may also only include the hostname. So what i want to do is something like:
find /home/ -type f -regextype posix-extended -regex '.*(string1|string2|`hostname`).*'
I'm not sure whether it's possible to somehow concat the output of the hostname command with the regex? Thanks in advance!
La solution
Try this :
find /home/ -type f -regextype posix-extended -regex ".*(string1|string2|$HOSTNAME).*"
if you need to use a command instead :
find /home/ -type f -regextype posix-extended -regex ".*(string1|string2|$(hostname)).*"