move command

Vom einfachen Programm zum fertigen Debian-Paket, Fragen rund um Programmiersprachen, Scripting und Lizenzierung.
Antworten
linuxCowboy
Beiträge: 287
Registriert: 05.02.2013 19:47:41

Re: move command

Beitrag von linuxCowboy » 26.12.2014 19:45:36

Fmvx () - Christmas Release:

Code: Alles auswählen

Fmvx ()
{
    [[ ! $2 || $1 = -h || $1 = --help || ! -f $1 || -e $2 && ! -d $2 ]] && 
        echo "\n\t $FUNCNAME filepath/file dir # file => dir/filepath/file\n" &&
            return

    local filepath=$1
    [[ $filepath =~ ^\.*/(.*) ]] && filepath=${BASH_REMATCH[1]}

    if [[ $filepath =~ / ]]; then
        filepath=${filepath%/*}
    else
        filepath=
    fi

    mkdir -p "${2%/}/$filepath" &&
        mv -v "$1" "${2%/}/$filepath"
}
Syntax Highlighting: NoPaste-Eintrag38186
-der_linux_cowboy --- Besser werden! ... f*** w$$

ren22

Re: move command

Beitrag von ren22 » 31.12.2014 15:53:41

dein Code in Kombination mit:

Code: Alles auswählen

(IFS=$'\n'; for i in `find -name '*.8'`;do Fmvx "$i" ../d2;done)
mal sehen ob man das auch auf mehrere Dateien umscripten kann ^^

TOP ... funktioniert bestens :THX: :THX: :THX: :THX: :THX: :THX: :THX: :THX: :hail: :hail: :hail: :hail:

Antworten