Search code examples
clinuxposixunlinkrm

unlink multiple files in a C linux program


I am trying to simulate the behavior of linux commandline command

rm a1*.txt

using either wildcards or regular expressions, inside a C program (linux gcc).

Is there a standard way of doing that?


Solution

  • If you're on a POSIX system, you can use glob() to expand such a pattern.

    Then, of course, use the standard remove() function to do the deletion.