How to concatenate files on linux without returning a line

I want to concatenate 2 files file1 and file2 into file3 without returning a line:

cat file1 #return AAAAAAA
cat file2 #return BBBBBBB

      

cat file1 file2 > file3

cat file3 #will return
AAAAA
BBBBB

      

I want to have AAAAABBBBB

+3


source to share


4 answers


This should work:

printf "%s%s\n" "$(<file1)" "$(<file2)" >file3

      



Or:

echo "$(<file1)$(<file2)" >file3

      

+3


source


Connect it to a command tr

that will remove newlines:



cat file1 file2 | tr -d "\n" > file3

      

+2


source


What about

$ echo $(cat aaa)$(cat bbb)
aaabbb

      

+1


source


Pearl for the rescue:

perl -pechomp file1 file2 file3... > file.out

      

See chomp .

0


source







All Articles