Nick Ginanto Nick Ginanto - 4 months ago 7
Bash Question

Transforming a list of files names to concatenated with space

I can do

git diff --name-only HEAD develop
which gives a list of file names like this:

a.txt
b.txt
c.txt


How can I transform this to be separated by space like this:

a.txt b.txt c.txt

Answer

use can use tr command to replace newline with space

echo file | tr '\n' ' '