Skip to content

Instantly share code, notes, and snippets.

@wellington1993
Created May 21, 2018 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wellington1993/113675add5622af8f017c14cf8172dce to your computer and use it in GitHub Desktop.
Save wellington1993/113675add5622af8f017c14cf8172dce to your computer and use it in GitHub Desktop.
Migraçao de laudos antigos Bash
#!/bin/bash
cd /DATA/laudos
# sincroniza estrutura de pastas (somente pastas)
rsync -avP --include="*/" --exclude="*" /DATA/laudos/ /laudos-antigos/laudos
# para cada arquivo dentro do diretorio atual
# onde sua data de criacao for superior a 90 dias
# mova para o disco laudos-antigos e crie um link
# no lugar do arquivo original
for x in $(find $(realpath $(pwd)) -type f -xtype f -mtime +90 -print); do mv $x $(dirname ${x/\/DATA\//\/laudos-antigos\/})\/ ; ln -s ${x/\/DATA\//\/laudos-antigos\/} $x ; echo 'Movido' $x ;done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment