eDeviser
eDeviser

Reputation: 1863

How to check if file exists using wildcard * in Erlang?

Imagine a directory with these files/folders: file_foo, file_bar, folder_a, folder, b

I need to search within this folder for a file which is named something with "foo". In bash I would normally do this by:

FOO_FILES=$(find . -name "*foo*")

How to check if file exists using wildcard * in Erlang?

Possible Soultions:

  1. Do I need to use file:list:dir to list the directories files/folders and then iterate oder the list using a regurlar expression matching my search pattern? Or is there a simpler way to do so?
  2. I tried using file:path_eval("D:/myFolder", "*foo*") but this did not work.

Upvotes: 2

Views: 273

Answers (1)

José M
José M

Reputation: 3509

You should use filelib:wildcard/1,2

Upvotes: 4

Related Questions