Nick Ginanto Nick Ginanto - 1 year ago 45
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 Source

use can use tr command to replace newline with space

echo file | tr '\n' ' '