As using the cat command, not more than two times, record the lines from stdin at the beginning and end of the file?

There is one file, it is necessary to record a random number of rows (writing exercise at the beginning and end of the file without losing the original strings already contained there).
This must be done with the CAT command with it to use it not more than 2 times. The strings themselves should be taken from standard input (example: cat - >> one )
March 19th 20 at 09:11
2 answers
March 19th 20 at 09:13
cat "файл_с_рандомными_строками_в_начало" "originalnymi" "файл_с_рандомными_строками_в_конец"> temp
cat temp > "originalnymi"


for example
$ echo "string3" > file.txt
$ cat file.txt - > temp.txt
string1
string2
*** PRESS CTRL+d to finish entering the row which will go to the top of the file
string4
string5
*** PRESS CTRL+d to finish entering the row which will go to the end of the file
$ cat temp.txt > file.txt
$ cat file.txt
string1
string2
string3
string4
$
The recording exercise And the beginning And the end of the file - danny_Nitzsche commented on March 19th 20 at 09:16
the second sign in the cat command if that displays nothing. by default it is hammered EOF (as I remember) - danny_Nitzsche commented on March 19th 20 at 09:19
@danny_Nitzscheyou try to start. The code works and the combination of ctrl+d is not just specified. - Brade commented on March 19th 20 at 09:22
then my bad.
it was necessary to specify that rows should be the same (the text must be duplicated and not with your hands) - danny_Nitzsche commented on March 19th 20 at 09:25
that is the same?
the command "cat - file > temp" means:
read from STDIN
read from file
read from STDIN
to put everything in temp.

When reading from STDIN you can enter as many lines, but to complete need to enter Ctrl+d - nayeli commented on March 19th 20 at 09:28
March 19th 20 at 09:15
Catом write down the first line from stdin to a temporary file, the second form cat the result file:
tmpfile tmpfile cat one>two
should be overwritten by the source file. the task implies that the result will be in the same named space. - danny_Nitzsche commented on March 19th 20 at 09:18
@danny_Nitzsche, then rename the file - Coleman52 commented on March 19th 20 at 09:21

Find more questions by tags bash