JavaRocky JavaRocky - 2 years ago 68
Bash Question

How to join multiple lines of file names into one with custom delimiter?

I would like to join the result of

ls -1
into one line and delimit it with whatever i want.

Are there any standard Linux commands I can use to achieve this?

zaf zaf
Answer Source

EDIT: Simply "ls -m" If you want your delimiter to be a comma

Ah, the power and simplicity !

ls -1 | tr '\n' ','

Change the comma "," to whatever you want. Note that this includes a "trailing comma"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download