display only file names

Hi,

I want to display only the file names of the ls command with a delimiter of comma.

For example:-

ls /etc/dir/N*

gives the following output

/etc/dir/N1 /etc/dir/N2 /etc/dir/N3

I want the output as N1,N2,N3,-->Here i need the final comma also.

Also, here /etc/dir is being passed as a parameter and hence will be dynamic

Please let me know how we can implement this.

Thanks.

ls --format=commas

at least on my version of ls :

he needs extra comma at the end.

/usr/bin/ls | tr "\n" ","

Try the "-m" switch. A "man ls" reveals:

-m     fill width with a comma separated list of entries

Then just suffix your last comma. I hope that helps some.

Cheers....Cassj