first code

This commit is contained in:
Bryan Joshua Pedini 2020-12-30 10:17:18 +01:00
parent 876947b977
commit 06609f2475
1 changed files with 35 additions and 0 deletions

35
filediff.sh Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Check for at least one parameter
if [ "$#" -lt 1 ]; then
cat >&2 << EOF
Usage: $0 <command> [parameters]
EOF
fi
# Check for commands existance
find &>/dev/null
if [ "$?" -ne 0 ]; then
cat >&2 << EOF
Unable to proceed without \`find\`.
EOF
fi
TMPDIR="$(mktemp -d)"
BEFORE="$TMPDIR/before.tree"
AFTER="$TMPDIR/after.tree"
find . > $BEFORE
output=$(eval "$@")
find . > $AFTER
if [ "$output" != "" ]; then
echo "$output"
echo
fi
diff --color=always $BEFORE $AFTER | tail -n-1
rm $TMPDIR/*
rmdir $TMPDIR