linuxstringbashshellparsing

How to join multiple lines of filenames into one with custom delimiter


How do I join the result of ls -1 into a single line and delimit it with whatever I want?


Solution

  • paste -s -d joins lines with a delimiter (e.g. ","), and does not leave a trailing delimiter:

    ls -1 | paste -sd "," -