Skip to content

Commit

Permalink
replace script
Browse files Browse the repository at this point in the history
  • Loading branch information
andys8 committed Jan 24, 2025
1 parent 9d4880a commit 58446ae
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bin/replace
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# replace - replace all occurrences of a pattern in input

if [ "$#" -lt 1 ]; then
echo "Usage: replace <pattern> [replacement]"
exit 1
fi

pattern="$1"
replacement="${2:-}"

while IFS= read -r line; do
echo "${line//$pattern/$replacement}"
done

0 comments on commit 58446ae

Please sign in to comment.