I have an question about how to insert a string into the second to last line of a file.
For example:
$ cat diff_a.txt
students
teacher
mike
john
$ cat diff_b.txt
python
bash shell
Java
Expected Result should be:
$ cat diff_b.txt
python
bash shell
mike
Java
If I use the following command, it will append string "mike" into the last line of diff_b.txt
$ grep mike diff_a.txt >> diff_b.txt
$ cat diff_b.txt
python
bash shell
Java
mike
Question:
How should I put "mike" into second to last line of diff_b.txt ?