Skip to content

Instantly share code, notes, and snippets.

@phanthaihuan
Created October 1, 2020 10:19
Show Gist options
  • Save phanthaihuan/fc092b5fd120baf5c53efc90bfe72cec to your computer and use it in GitHub Desktop.
Save phanthaihuan/fc092b5fd120baf5c53efc90bfe72cec to your computer and use it in GitHub Desktop.
Insert text at specific line in bash
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