Sorry for a noob question but, well, I am a noob, so...
Given two files, say file1
with content, say, text1
and file2
with content text2
, I want to create a new file file3
with content text1newtextinbetweentext2
. I would expect some command like
cat file1 (dontknowwhat "newtextinbetween") file2 > file3
Is there some dontknowwhat
that would do what I want? If not, what is the optimal way to do it?
printf '%snewtextinbetween%s\n' "$(<file1)" "$(<file2)"
if you're not a cat lover – steeldriver Dec 03 '20 at 17:11newtextinbetween
was the value of some variableWHATTOINSERT
; would something likeprintf '%s($WHATTOINSERT)%s\n'...
work then? – მამუკა ჯიბლაძე Dec 03 '20 at 17:14%s
like this:printf '%s%s%s\n' "$(cat file1)" "$WHATTOINSERT" "$(cat file2)" > file3
– terdon Dec 03 '20 at 18:36{
to group instead of(
. – rowboat Dec 04 '20 at 00:35