Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ## If direcotry '_Backup' doesnt exists, create it
- if test ! -d "_Backup"
- then
- mkdir _Backup
- echo "Das Verzeichnis '_Backup' existierte noch nicht und wurde erstellt"
- fi
- for f in $(ls)
- do
- ## File is no directory
- if test ! -d "$f"
- then
- ## Should file copy or not
- read -p "Soll die Datei '$f' kopiert werden? [y|n]" yn
- case $yn in
- [Yy] )
- ## Append _cp if file already exists in '_Backup'
- newfile=$f
- if test -e "_Backup/$f"
- then
- newfile=$newfile"_cp"
- echo "'$f' existiert bereits im Verzeichnis '_Backup' -> wird kopiert als '$newfile'"
- fi
- ## Copy file
- cp $f "_Backup/$newfile"
- echo "Datei '$f' wurde kopiert"
- ;;
- * ) echo "skipping file '$f'";;
- esac
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement