Created
September 6, 2019 15:40
-
-
Save amaalali/91172d835d0c743b5d95f4cbf9db8575 to your computer and use it in GitHub Desktop.
Bash script with awk to replace text in files
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
#!/bin/bash | |
echo "Applying changes" | |
echo "" | |
declare -a arr=( | |
"file1" | |
"file2" | |
) | |
for file in "${arr[@]}" | |
do | |
echo "Start File: $file" | |
awk '/<-- Text For Search Goes here -->/{gsub(<-- Text For Search Goes here -->, "<-- Text to replace here -->")};{print}' $file > tmp && mv tmp $file | |
echo "End File: $file" | |
echo "" | |
done | |
echo "Changes complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment