I want to merge two files cat file1 file2 > file3
. But it starts with new line. I don't want that. I could use tr to replace all new lines to space, but I can't do that, because there are new lines in files which I don't want to replace.
You could use head
with -1
as the -c
flags parameter and -q
head -c -1 -q file1 file2 > file3
head -c -1
will output everything up to the last 1 byte of the code (in this case the last 1 byte - endline - wont be included). The -q
is so the filenames dont get piped to file3
as head
does by default when head
ing multiple files.
Or, as suggested by this answer - bash cat multiple files content in to single string without newlines
, pipe it to tr
:
tr -d "\n"
in bash, you can do:
cat <(sed -n '1n;p' file1) <(sed -n '1n;p' file2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With