Home » Questions » Computers [ Ask a new question ]

How can one join files with seperating data in bash?

How can one join files with seperating data in bash?

So one can easily join files in bash with cat:

Asked by: Guest | Views: 309
Total answers/comments: 1
bert [Entry]

"Requires GNU sed:

sed -s '$G' *.txt > all.txt

append a line of 8 dashes and a newline after each file

sed -s '$a--------' *.txt

You can use your sed '$d' with that

Compare to these:

Insert a line of dashes before each file:

sed -s '1i--------' *.txt

Do the same, but without a newline after the dashes:

sed -s '1s/^/--------/' *.txt

Put a line of dashes on the end of the last line of each file:

sed -s '$s/$/--------/' *.txt

Surround each file with curly braces:

sed -s -e '1i{' -e '$a}' *.txt"