Add dellines script
This commit is contained in:
parent
13eae31075
commit
37dbd9d6e0
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# dellines deletes lines in multiple files matching a regex
|
||||||
|
# Example: dellines '^//' src/ *.go
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
matchpattern="$1"
|
||||||
|
path="$2"
|
||||||
|
filepattern="$3"
|
||||||
|
|
||||||
|
if [ -z "$path" ]; then
|
||||||
|
echo "Usage: dellines <pattern> <path>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$filepattern" ]; then
|
||||||
|
filepattern="*"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $(uname -s) = "Linux" ]; then
|
||||||
|
echo "TODO: fix for Linux"
|
||||||
|
fi
|
||||||
|
|
||||||
|
find "$path" -type f -name "$filepattern" -print0 | LC_CTYPE=C LANG=C xargs -0 sed -i '' "/$matchpattern/d"
|
Loading…
Reference in New Issue