Created
May 10, 2022 22:23
-
-
Save alanhoyle/80fef560c91ed40f48f2fb41f2ab2e02 to your computer and use it in GitHub Desktop.
Insert line in file and keep timestamp
This file contains hidden or 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
temp_file=$(mktemp) | |
touch -r $1 $temp_file | |
sed -i '/^.*put something above me.*/i text_to_be_inserted' $1 | |
touch -r $temp_file $1 | |
rm $temp_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment