How to turn many lines into one line

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.

Last Updated: 2024-03-02

Let's say your paste buffer contains the following data (representing dependencies)

"beyondcode/laravel-dump-server"
"filp/whoops"
"fzaninotto/faker"
"laravel/dusk"
"mockery/mockery"
"nunomaduro/collision"
"nunomaduro/larastan"
"phpstan/phpstan"
"phpunit/phpunit"
"shvetsgroup/laravel-email-database-log"

You want to join them all onto one line (e.g. because you want to feed them all as arguments to a command for installing a list of dependencies)

The trick is to use tr with -d set to \n to remove the newlines.

pbpaste |  tr -d '\n'

"beyondcode/laravel-dump-server"        "filp/whoops"        "fzaninotto/faker"        "laravel/dusk"        "mockery/mockery"        "nunomaduro/collision"        "nunomaduro/larastan"        "phpstan/phpstan"        "phpunit/phpunit"        "shvetsgroup/laravel-email-database-log"%