1

I want to target all files called fooxxxbarxxx. The common thing among all those files is that it contains foo and bar.

I've tried to use *foo*bar* and *foo**bar* but it doesn't work.

Specifically, I'm trying to create soft links to those files, and the rest of the code already works for more straightforward executions (looks into all subfolders of path):

shopt -s globstar

ln -s /path/**/*foo*bar* .

Thanks

3

2 Answers 2

1

In bash shell you need to use extglob option for this OR type shell expansions.

shopt -s extglob nullglob

and then do the globbing as

ln -s /path/**/@(*foo*bar*|*bar*foo*)
0
0

POSIXly:

find /path -name '.*' -prune -o -name '*foo*' -name '*bar*' -exec sh -c '
  ln -s "$@" .' sh {} +

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.