title: How to implement "ls a*" in Nodejs to list specific files in a directory (readdir lists all)?
body: <p>I have a directory in which there are many files and I want to pick only one file that I know starts with a certain prefix and thats it. One easy way to find if such a file exists is to use <a href="https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback" rel="nofollow">readdir</a> or <a href="https://nodejs.org/api/fs.html#fs_fs_readdirsync_path_options" rel="nofollow">readdirSync</a> to get an array with names of all files and then check if one of them starts with the string I have.</p>
  
  <p>That I think is inefficient because of the number of files in the directory. Is there a better way to accomplish this and particularly so because there is only one file in the folder whose prefix will match the one I specify.</p>