ajout de regcp et regmv
This commit is contained in:
parent
5e33a36bcd
commit
93de256914
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
|
source "$(dirname -- "$0")/lib/ulib/auto" || exit 1
|
||||||
urequire DEFAULTS
|
|
||||||
|
|
||||||
function display_help() {
|
function display_help() {
|
||||||
uecho "$scriptname:
|
uecho "$scriptname:
|
||||||
|
|
|
@ -42,6 +42,7 @@ done
|
||||||
./ulink --nutools-makelinks
|
./ulink --nutools-makelinks
|
||||||
./doinplace --nutools-makelinks
|
./doinplace --nutools-makelinks
|
||||||
./fndate --nutools-makelinks
|
./fndate --nutools-makelinks
|
||||||
|
./regcp --nutools-makelinks
|
||||||
|
|
||||||
# complétion programmable
|
# complétion programmable
|
||||||
rm -f ~/etc/bashrc.d/bash_completion.nutools # renommé
|
rm -f ~/etc/bashrc.d/bash_completion.nutools # renommé
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
|
ALIASES=(regmv)
|
||||||
|
if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
|
||||||
|
# créer les liens
|
||||||
|
scriptname="$(basename "$0")"
|
||||||
|
for alias in "${ALIASES[@]}"; do
|
||||||
|
ln -s "$scriptname" "$alias"
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
source "$(dirname -- "$0")/lib/ulib/auto" || exit 1
|
||||||
|
|
||||||
|
case "$scriptname" in
|
||||||
|
regcp)
|
||||||
|
VERB="copier"
|
||||||
|
CMD=cp
|
||||||
|
;;
|
||||||
|
regmv)
|
||||||
|
VERB="déplacer"
|
||||||
|
CMD=mv
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
function display_help() {
|
||||||
|
uecho "$scriptname: $VERB un fichier vers une destination construite avec une expressions régulière
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
$scriptname REGEXP FILEs....
|
||||||
|
|
||||||
|
NB: l'expression régulière est traitée avec sed"
|
||||||
|
}
|
||||||
|
|
||||||
|
args=(--help '$exit_with display_help')
|
||||||
|
parse_args "$@"; set -- "${args[@]}"
|
||||||
|
|
||||||
|
regexp="$1"; shift
|
||||||
|
[ -n "$regexp" ] || die "l'expression régulière est requise"
|
||||||
|
|
||||||
|
for src in "$@"; do
|
||||||
|
dest="$(sed "$regexp" <<<"$src")"
|
||||||
|
if [ "$src" == "$dest" ]; then
|
||||||
|
eerror "$src: refus de $VERB le fichier sur lui-même"
|
||||||
|
else
|
||||||
|
estep "$src --> $dest"
|
||||||
|
"$CMD" "$src" "$dest" || die
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue