Skip to content

Commit

Permalink
add search and replace
Browse files Browse the repository at this point in the history
  • Loading branch information
jrichardsz committed Aug 8, 2022
1 parent cdd407f commit 5fe874d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions commands/replace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
file_location=$1
string_to_search=$2
string_to_replace=$3

string_to_search_scaped=$(echo $string_to_search | sed 's_/_\\/_g')
string_to_replace_scaped=$(echo $string_to_replace | sed 's_/_\\/_g')

echo "search ocurrences of: $string_to_search_scaped"
grep -rnw $file_location -e $string_to_search_scaped | wc -l


sed -e "s/$string_to_search_scaped/$string_to_replace_scaped/g" $file_location

echo "search ocurrences of: $string_to_search"
grep -rnw $file_location -e $string_to_search | wc -l
9 changes: 9 additions & 0 deletions commands/search.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
file_location=$1
string_to_search=$2
string_to_replace=$3

string_to_search_scaped=$(echo $string_to_search | sed 's_/_\\/_g')
string_to_replace_scaped=$(echo $string_to_replace | sed 's_/_\\/_g')

echo "search ocurrences of: $string_to_search_scaped"
grep -rnw $file_location -e $string_to_search_scaped | wc -l

0 comments on commit 5fe874d

Please sign in to comment.