Comparando arquivos por data
Publicado por Guinux (última atualização em 31/05/2013)
[ Hits: 9.047 ]
Homepage: www.software.inf.br
Depois de muito procurar, e não encontrar, resolvi desenvolver um script que recebe dois arquivos e retorna qual é o mais recente.
Espero que seja útil.
Abraços.
#!/bin/bash # # data.sh - # # Site : http://www.software.inf.br # Autor : Guilherme Giuliani <guilherme@software.inf.br> # Manutenção: Guilherme Giuliani <guilherme@software.inf.br> # # ------------------------------------------------------------------------- # Este programa recebe dois arquivos e retorna qual mais atual # ------------------------------------------------------------------------- # # # Histórico: # # v1.0 2013-05-29, Guilherme Giuliani: # - Versão inicial do programa # # # Ex. de Uso: $ ./data.sh arq1 arq2 # Licença: GPL. # #0=IGUAL #1=RECENTE #2=ANTIGO DD1=`date -r $1 +%d`; MM1=`date -r $1 +%m`; AA1=`date -r $1 +%Y`; H1=`date -r $1 +%H`; M1=`date -r $1 +%M`; S1=`date -r $1 +%S`; DD2=`date -r $2 +%d`; MM2=`date -r $2 +%m`; AA2=`date -r $2 +%Y`; H2=`date -r $2 +%H`; M2=`date -r $2 +%M`; S2=`date -r $2 +%S`; if [[ "AA1" -gt "AA2" ]]; then status="1"; elif [[ "AA1" -lt "AA2" ]]; then status="2"; elif [[ "AA1" -eq "AA2" ]]; then if [[ "MM1" -gt "MM2" ]]; then status="1"; elif [[ "MM1" -lt "MM2" ]]; then status="2"; elif [[ "MM1" -eq "MM2" ]]; then if [[ "DD1" -gt "DD2" ]]; then status="1"; elif [[ "DD1" -lt "DD2" ]]; then status="2"; elif [[ "DD1" -eq "DD2" ]]; then if [[ "H1" -gt "H2" ]]; then status="1"; elif [[ "H1" -lt "H2" ]]; then status="2"; elif [[ "H1" -eq "H2" ]]; then if [[ "M1" -gt "M2" ]]; then status="1"; elif [[ "M1" -lt "M2" ]]; then status="2"; elif [[ "M1" -eq "M2" ]]; then if [[ "S1" -gt "S2" ]]; then status="1"; elif [[ "S1" -lt "S2" ]]; then status="2"; elif [[ "S1" -eq "S2" ]]; then status="0"; fi fi fi fi fi fi echo $status
zsh: Sattolo's Random Cyclic Permutation
Instalação do Cisco Packettracer 7.2 no Debian 10
Customizar a Instalação do Linux Debian com Preseed
Atualizando o Passado: Linux no Lenovo G460 em 2025
aaPanel - Um Painel de Hospedagem Gratuito e Poderoso
Um modo leve de ouvir/ver áudio/vídeo da internet em máquinas pererecas
Resolver algumas mensagens de erro do SSH
Instalar módulo de segurança do Banco do Brasil Warsaw do tipo .run
Sem espaço na partição home (4)
Aprendendo mais sobre Linux com livro (6)
Procrastinação e autossabotagem são problemas muito comuns na sociedad... (6)