Get all files in the directory as a comma separated list

You can use the ls command to get a list of all the files in the current directory as a comma separated list using the following:

ls -m

If you want to exclude any subdirectories, try this:

ls -mp | grep -v "/"

Note you may end up with a trailing comma depending on whether the last item is a directory or not.