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.
Question:
How can I list the directories comma separated?
how can I add this list as -d parameter to the phpdoc script?
Linux ls command can output the contents of a directory separated by comma when used with the switch (-m).
You can use the GNU ls -m command. It will print all files and dir separated by comma.
Copying Directories with cp Command To copy a directory, including all its files and subdirectories, use the -R or -r option. The command above creates the destination directory and recursively copy all files and subdirectories from the source to the destination directory.
Use ls -dm */
to generate a comma-separated list of directories. -d
will return directories only and -m
will output to a comma-separated list.
You could then store the output in a variable and pass it along as an argument:
#!/bin/bash MY_DIRECTORY=/some/directory FOLDERS=`ls -dm $MY_DIRECTORY/*/ | tr -d ' '` phpdoc -d $FOLDERS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With