29 lines
374 B
Plaintext
29 lines
374 B
Plaintext
|
#! /bin/sh
|
||
|
|
||
|
filter="$1"
|
||
|
src="$2"
|
||
|
dest="$3"
|
||
|
|
||
|
root="$(pwd)"
|
||
|
|
||
|
rm -r "$dest"
|
||
|
cp -r "$src" "$dest"
|
||
|
|
||
|
files="$(find "$dest" -type f)"
|
||
|
|
||
|
for file in $files; do
|
||
|
file "$file" | grep -q 'text' || continue
|
||
|
cd "$(dirname "$file")" || exit 1
|
||
|
|
||
|
file="$(basename "$file")"
|
||
|
|
||
|
exec 3< "$file"
|
||
|
rm "$file"
|
||
|
|
||
|
sh -c "$filter" <&3 > "$file"
|
||
|
|
||
|
exec 3>&-
|
||
|
|
||
|
cd "$root"
|
||
|
done
|