php - Get filename from Unix "ls -la" command with regexp? -


How can I generate a regular expression pattern that returns the file name from any one line? (I'll search one line at a time).

  drwxrwxrwx 4 Apache Apache 4096 October 14 09:40. Drwxrwxrwx 11 apache apache 4096 October 13 11:33 .. -RWXRVXRWX1 Apache Apache 16507 October 17 10:16 .bash_history -rwxrwxrwx 1 Apache Apache 33 September 19:36 .bash_logout -rwxrwxrwx 1 Apache Apache 176 September 1 09:36. Bash_profile -rwxrwxrwx 1 Apache Apache 124 Sep 1 09:36 .bashrc -rwxrwxrwx 1 Apache Apache 515 September 1 09:36 .emacs -rw ------- 1 christoffer christoffer 11 993 September 18 10:00 .mysql_history drwxrwxrwx 3 Apache Apache 4096 September 1 09:48. Schuyzance -RWDRVXRWX1 Christopher Christophfer 9 204 14 October 09:40 .minfu dwyxrwoxdwox 14 apache apache 4096 October 12 07:39 www  

Search is used in PHP but I think That really does not matter :)

Edit: The file list is received by an SSH connection and that is why I created a built-in PHP-function Sub Industry do not. I need this full list to see if a file is actually a directory or not.

LS-A1F instead it will give you all the entries ( -a ), one per line ( -1 ), will be listed with additional information about the file type added with the name ( -F ).

Then you will probably find something like this for your directory:

  ./../ .bash_history .bash_logout .bash_profile .bashrc .emacs .mysql_history .subversion / .viminfo Www /  

The directory has a slash / in the end.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -