NoPaste

Symlink Exclude

von linuxCowboy
SNIPPET_DESC:
script
SNIPPET_CREATION_TIME:
02.07.2015 21:57:55
SNIPPET_PRUNE_TIME:
Unendlich

SNIPPET_TEXT:
  1. #!/bin/bash
  2.  
  3. target=${1-/home/csgo/game/output}      # param 1
  4. cs=${2-/home/csgo/game/csgo-deagle1}    # param 2
  5.  
  6. mkdir -p "$target"
  7.  
  8. [[ ! -d $cs || ! -d $target ]] && echo "not 2 dirs" && exit 1
  9.  
  10. find "$cs" -type f |
  11.         while read f; do
  12.                 filepath=$f
  13.                 [[ $filepath =~ ^\.*/(.*) ]] && filepath=${BASH_REMATCH[1]}
  14.  
  15.                 if [[ $filepath =~ / ]]; then
  16.                         filepath=${filepath%/*}
  17.                 else
  18.                         filepath=
  19.                 fi
  20.  
  21.                 mkdir -p "${target%/}/$filepath"
  22.  
  23.                 if [[
  24.                         $f == *.conf  ||
  25.                         $f == *.cfg   ||
  26.                         $f == *txt    ||
  27.                         $f == *.ini   ||
  28.                         $f == *.smx   ||
  29.                         $f == *.mp3   ||
  30.                         $f == *.sh
  31.                 ]]; then
  32.                         echo -n "copy: "
  33.                         cp -v "$f" "${target%/}/$filepath"
  34.                 else
  35.                         echo -n "link: "
  36.                         ln -sfv "$f" "${target%/}/$filepath"
  37.                 fi
  38.         done | sort

Quellcode

Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN