Last active
October 18, 2016 14:25
-
-
Save fahadsiddiqui/fddedb3ca495a705e83b806a0f5b2a12 to your computer and use it in GitHub Desktop.
Write in between a file
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
SOME_STRING="exit 0" | |
PATH_TO_YOUR_FILE="./file" | |
cat $PATH_TO_YOUR_FILE | head -n `expr $(echo $(cat -n $PATH_TO_YOUR_FILE | grep "$SOME_STRING" | tail -n 1) | cut -d ' ' -f 1) - 1` > $PATH_TO_YOUR_FILE | |
echo -e "Hello world\n$SOME_STRING" >> $PATH_TO_YOUR_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment