Brian T Hannan Brian T Hannan - 1 year ago 50
Linux Question

How can I modify this regular expression to grab the filename from ls -a output?

Let's say I already have the output of an 'ls -la' command and I now want to parse out just the filenames. I have this regular expression so far that I found, but how can I modify this to account for there being whitespace in the filename itself?

Example 'ls -la' output:

-rw-r--r-- 1 admin staff 460340057 May 4 14:19 test_large_file.xml

Regular Expression I have so far:


Answer Source

You can use something like: