2

Trying to set GREP_OPTIONS to exclude certain file types in .bashrc.

GREP_OPTIONS=--exclude=*.{ext1,ext2,ext3*}
(ext3 may be ext3etc so need to account for that too)

This doesn't work. I've tried escaping various parts, quoting it different ways, but still nothing. Viewing the variable in the terminal just shows as typed in the .bashrc, exactly as above (obviously incorrect).

I used this method in a .cshrc file and it worked fine. When viewing the GREP_OPTIONS variable in the terminal, it would show as

GREP_OPTIONS=--exclude=*.ext --exclude=*.ext2

This question shows grep recognizes this style of globbing, and I've used it in the terminal and it works fine, but I just can't get it to work from within .bashrc.

How do I use globbing of this style in .bashrc?

Community
  • 1
  • 1
Mike Dannyboy
  • 462
  • 1
  • 4
  • 13

1 Answers1

3

You can let shell expand the list while doing this assignment in .bashrc:

export GREP_OPTIONS="$(echo --exclude=*.{ext1,ext2,ext3*})"
anubhava
  • 761,203
  • 64
  • 569
  • 643