Skip to content

Instantly share code, notes, and snippets.

@mehikmat
Created March 2, 2014 13:25
Show Gist options
  • Save mehikmat/9306522 to your computer and use it in GitHub Desktop.
Save mehikmat/9306522 to your computer and use it in GitHub Desktop.
Bash script to find and replace texts inside a file
...............
..................
#### Function to find and replace a text inside file using bash
updateLateCommandURLInPreseedFile(){
echo "[INFO]:: Updating late command url in pressed.cfg file**************"
echo ""
cat preseed.cfg | sed 's_${IPADDR}_'"$IP"'_g' > temp.cfg
cat temp.cfg > preseed.cfg
rm temp.cfg
echo "[INFO]:: Successfully substituted IP address of late command server****************"
}
#### Calling function
updateLateCommandURLInPreseedFile
................
..................
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment