superbly superbly - 6 months ago 29
Linux Question

Get all directories comma separated and send output to other script

We use phpDocumentator to document our php code.
The php code is in different dictionaries.
The script which runs the phpDocumentator looks like this:

./phpdoc -d dir1,dir2,dir3,dir4

Every time we add a new directory, I have to add this one to the script.

I would like to do this dynamically.

ls -d ../*test*

this lists all needed directories but space separated and not comma separated.


How can I list the directories comma separated?

how can I add this list as -d parameter to the phpdoc script?


Use ls -dm */ to generate a comma-seperated list of directories. -d will return directories only and -m will output to a comma-seperated list.

You could then store the output in a variable and pass it along as an argument:

FOLDERS=`ls -dm $MY_DIRECTORY/*/ | tr -d ' '`
phpdoc -d $FOLDERS