![]() |
|
|
google unix.com
|
|||||||
| Fóruns | Registar | Fórum Regimento | Ligações | Álbuns | FAQ | Lista deputados | Calendário | Pesquisa | Today's Posts | Mark Forums Read |
| Programação Shell Script e Post perguntas sobre ksh, CSH, SH, BASH, Perl, PHP, SED, Awk e outros scripts shell e shell scripts línguas aqui. |
Mais UNIX e Linux Fórum Tópicos Você pode achar Helpfull
|
||||
| Fio | Thread Starter | Fórum | Respostas | Última postagem |
| Como ontem DATA | osymad | Programação Shell Script e | 19 | 09-23-2009 03:39 |
| Ajuda, Preciso de ir buscar a última data do mês anterior | sirrtuan | Programação Shell Script e | 11 | 10-14-2008 06:59 |
| no mês passado, data de término | vanathi | UNIX & avançada para usuários experientes | 7 | 03-21-2008 04:17 |
| Como mostrar ontem data | wind_n_cloud | Programação Shell Script e | 1 | 02-16-2005 10:51 |
| chegar ontem à data no formato aaaammdd | hk_newbie | UNIX para Dummies Perguntas & Respostas | 2 | 12-14-2001 03:32 |
![]() |
|
|
Linkback | Thread Tools | Pesquisar este Thread |
Avaliação:
|
Display Modes |
|
|
|
||||
|
ontem à data mês / dia
Oi perito,
Eu quero recuperar ontem su log. Como calcular e atribuir valor variável (06/23) em myVariable? #! / bin / sh \u003d ontem myVariable data no mês / dia cat / var / adm / sulog | grep $ myVariable> file.txt muito obrigado! |
|
||||
|
Eu não acho que tenho isso. Como verificar?
Eu posso extrair a data, vamos dizer 24. Mas como fazer -1 Como corrigir código abaixo da sintaxe em / bin / sh myDate \u003d `date-u +% d` myMonth \u003d `date-u +% m` myYear \u003d `date-u +% Y` myAnotherMonth \u003d `date-u +% b` if [$ myDate \u003d\u003d 1 & & ($ myAnotherMonth \u003d\u003d Set | | $ myAnotherMonth \u003d\u003d abr | | $ myAnotherMonth \u003d\u003d junho | | $ myAnotherMonth \u003d\u003d novembro | | $ myAnotherMonth \u003d\u003d fevereiro)] então ontem \u003d 30 elseif [$ myDate \u003d\u003d 1 & & $ myAnotherMonth \u003d\u003d fev.] ontem \u003d 28 # Eu não se preocupe em terminar com 29 meses diferente ontem \u003d $ myDate - 1 fi cat / var / adm / sulog | grep "$ myMonth \ / $ ontem" | grep-v grep> $ myYear $ myMonth $ yesterday_sulog.txt Última edição por skully; em 06/24/2008 04:28.. |
|
||||
|
Para conhecer a sua versão do data, Basta executar o meu comando e ver o que sua caixa resposta.
Uma solução alternativa, mas novamente com GNU data: Código:
#!/bin/bash STAMP_TODAY=$(date --utc --date "$1" +%s) STAMP_YESTERDAY=$((STAMP_TODAY-86400)) DTE_YESTERDAY=$(date --utc --date "1970-01-01 $STAMP_YESTERDAY sec" "+%m/%d") echo $DTE_YESTERDAY |
|
||||
|
Se você não tem GNU data, Experimente isto em bash:
Código:
TODAY_D=$(date -u +%d)
TODAY_M=$(date -u +%m)
LAST_DAY_OF_M=(-- 31 28 31 30 31 30 31 31 30 31 30 31)
if [[ $TODAY_D == "01" ]];then
if [[ $TODAY_M == "01" ]];then
PREVIOUS_M="12"
else
PREVIOUS_M=$((TODAY_M-1))
fi
printf "%02d/%s" $PREVIOUS_M ${LAST_DAY_OF_M[$PREVIOUS_M]}
else
printf "%s/%s" $TODAY_M $((TODAY_D-1))
fi
exit 0
Última edição por ripat; em 06/24/2008 06:39.. Motivo: Esqueceu a cuidar de janeiro! |
![]() |
| Marcadores |
| Thread Tools | Pesquisar este Thread |
| Display Modes | Esta taxa Thread |
|
|