Answer the question
In order to leave comments, you need to log in
How to write lines from stdin to the beginning and end of the file using the cat command, no more than two times?
There is a file one, it is necessary to write a random number of lines into it (write to the beginning and end of the file, without losing the original lines already contained there).
This must be done with the CAT command, and use it no more than 2 times. The strings themselves must be taken from standard input (example: cat - >> one )
Answer the question
In order to leave comments, you need to log in
cat "файл_с_рандомными_строками_в_начало" "оригинальный_файл" "файл_с_рандомными_строками_в_конец"> temp
cat temp > "оригинальный_файл"
$ echo "string3" > file.txt
$ cat - file.txt - > temp.txt
string1
string2
*** НАЖАТЬ CTRL+d для завершения ввода строк которые пойдут в начало файла
string4
string5
*** НАЖАТЬ CTRL+d для завершения ввода строк которые пойдут в конец файла
$ cat temp.txt > file.txt
$ cat file.txt
string1
string2
string3
string4
$
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question