 <p>Instead of trying to parse the output of <code>ls</code>, <a href="http://mywiki.wooledge.org/ParsingLs" rel="nofollow">which is bad</a>, you should simply use file system operation provided by node.js. Using file system operations you can be sure your program will work in (almost) any edge case as the output is well defined. It will even work in case the folder will contain more or less files than three in the future!</p> <p>As you stated in the comments that you want the names and date / time of the files from a folder. So let us have a look at:</p> <p><a href="http://nodejs.org/api/fs.html#fs_fs_readdir_path_callback" rel="nofollow"><code>fs.readdir(path, callback)</code></a>: <code>fs.readdir</code> will give you an array of filenames in the folder specified in path. You can pass them to <code>fs.stat</code> to find out the mtime:</p> <p><a href="http://nodejs.org/api/fs.html#fs_fs_fstat_fd_callback" rel="nofollow"><code>fs.stat(path, callback)</code></a>: <code>fs.stat()</code> will give you an object of <a href="http://nodejs.org/api/fs.html#fs_class_fs_stats" rel="nofollow"><code>fs.Stats</code></a> which contains the mtime in the <code>mtime</code> property.</p> <p>So your code will look something like this afterwards:</p> <pre><code>fs.readdir('dir', function (err, files) { for (var i = 0; i &lt; files.length; i++) { (function () { var filename = files[i] fs.stat('dir/' + filename, function (err, stats) { console.log(filename + " was last changed on " + stats.mtime); }); })(); } }); </code></pre> <p>The output is:</p> <pre><code>[timwolla@~/test]node test.js 5 was last changed on Fri Mar 01 2013 20:24:35 GMT+0100 (CET) 4 was last changed on Fri Mar 01 2013 20:24:34 GMT+0100 (CET) 2 was last changed on Fri Mar 01 2013 20:24:33 GMT+0100 (CET) </code></pre> <p>In case you need a return value use the respective <code>Sync</code>-versions of these methods. These, however, will block your node.js eventing loop.</p>