view raw
Nick Ginanto Nick Ginanto - 9 months ago 34
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' ' '