-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add typos tool to check and correct typograp
- Loading branch information
1 parent
94ec4d9
commit b3049da
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Function to check for typos | ||
check_typos() { | ||
local dir=$1 | ||
grep -r -n "teh" $dir | ||
grep -r -n "an d" $dir | ||
grep -r -n "fro " $dir | ||
} | ||
|
||
# Function to correct typos | ||
correct_typos() { | ||
local file=$1 | ||
local typo=$2 | ||
local correct=$3 | ||
sed -i "s/$typo/$correct/g" $file | ||
} | ||
|
||
# Main function | ||
main() { | ||
local dir=$1 | ||
check_typos $dir | ||
correct_typos $dir "teh" "the" | ||
correct_typos $dir "an d" "and" | ||
correct_typos $dir "fro " "for" | ||
} | ||
|
||
main $1 |