0

I want to find certain files, and loop over them, to print their names. What I have done is

DRAFT_FILES=(`find "$DRAFT_DIR" -name "*.md"`)

This gives me an array of all markdown files in the directory.

However, this is apparently not modern bash, according to ShellCheck and this guide, apparently the backtick is not good style. They recommend doing "$( ... )", as far as I can tell. However, this

DRAFT_FILES="$(find $DRAFT_DIR -name '*.md')"

It only stores the first file found.

Can anyone help me?

I have looked at these answers before, but they seem to be outdated.

1, 2.

Vegard Stikbakke
  • 749
  • 1
  • 7
  • 21

0 Answers0