Created
October 1, 2020 10:19
-
-
Save phanthaihuan/fc092b5fd120baf5c53efc90bfe72cec to your computer and use it in GitHub Desktop.
Insert text at specific line in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://unix.stackexchange.com/questions/271475/insert-text-at-specific-line-number | |
head -n 2 ./file.txt > newfile.txt | |
echo "text to insert" >> newfile.txt | |
tail -n +3 ./file.txt >> newfile.txt | |
mv newfile.txt file.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment