-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrg
executable file
·44 lines (42 loc) · 820 Bytes
/
wrg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
echo "replaceing $1 to $2"
rg $1 --files-with-matches | xargs sd $1 $2
echo "done :-)"
# seenReplace=''
#
# for arg in "$@"; do
# if test "$arg" == '--replace' -o "$arg" == '-r'; then
# seenReplace='true'
# break
# fi
# done
#
# if test -z "$seenReplace"; then
# echo 'You must specify the --replace or -r argument!'
# exit 1
# fi
#
# currentFile=''
# didChange=''
#
# (
# rg \
# --files-with-matches \
# "$@"
# echo -e '\n\0'
# ) |
# {
# while IFS= read -r -d '' part; do
# if test -n "$currentFile"; then
# echo "$currentFile"
# head -n -2 <<< "$part" > "$currentFile"
# didChange='true'
# fi
# currentFile="$(tail -n 1 <<< "$part")"
# done
#
# if test -z "$didChange"; then
# echo "No files were changed."
# exit 1
# fi
# }