in reply to File regex question

Why is it that you're doing this? Are you going to take that file and pull it into a spreadsheet? Are you actually planning on renaming your files and directories to have underscores in them?

If you're passing this data to another application that will choke on the spaces, you may want to check and see if quoting the directory/file names will work. Then you could do something like....

perl -i.bak -lne '@F=split(/ /,$_,3);print "$F[0] $F[1] \"$F[2]\""' filename

Of course, that doesn't take into account any lines not matching the expected format (e.g., blank lines are no longer blank)