moving tools from another repo

This commit is contained in:
Q
2024-10-11 21:35:44 +03:00
parent 8979ccf296
commit 3fbd5860e0
6 changed files with 125 additions and 0 deletions

29
files/archive-extract2folder Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
set -e
for arch in "$@"; do
case "$arch" in
*.tar) D="`basename "$arch" .tar`"; U="tar -x -v -f"; ;;
*.tar.gz) D="`basename "$arch" .tar.gz`"; U="tar -x -z -v -f"; ;;
*.tgz) D="`basename "$arch" .tgz`"; U="tar -x -z -v -f"; ;;
*.tar.Z) D="`basename "$arch" .tar.Z`"; U="tar -x -Z -v -f"; ;;
*.tar.z) D="`basename "$arch" .tar.z`"; U="tar -x -Z -v -f"; ;;
*.tar.bz2) D="`basename "$arch" .tar.bz2`"; U="tar -x -j -v -f"; ;;
*.zip) D="`basename "$arch" .zip`"; U="unzip"; ;;
*.rar) D="`basename "$arch" .rar`"; U="unrar x"; ;;
esac
if [[ -z "$FORCE_EXTRACT" ]]; then
echo "extract $arch to $PWD/$D/?"
read foo
else
echo "extracting $arch to $PWD/$D/"
fi
mkdir -p "$D"
archive=$( realpath "$arch" )
pushd "$D"
$U "$archive"
popd
done
sleep 1

35
files/split-q Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
CMD="split -d -a 4"
_help() {
split --help
echo ""
echo "My default switches for split utility"
echo "$CMD -b 500M FILE FILE."
}
_helpexit() {
_help
exit
}
for (( i=1; i<=$#; i++ )); do
[[ ${!i} = "-h" ]] && _helpexit
[[ ${!i} = "--help" ]] && _helpexit
done
args=( )
for (( i=1; i<=$#; i++ )); do
test -f "${!i}" && {
file="${!i}"
# file found, remove from arguments
set -- "${@:1:i-1}" "${@:i+1}"
}
[[ "${!i}" = "-b" ]] && SIZE_SET=1
done
[[ "$SIZE_SET" -eq 1 ]] || {
size="-b 500M"
}
test -f "$file" || { echo "No such file"; exit 1; }
set -x
pv "$file" | $CMD $size "$@" - "$file".