![]() |
|
|
google unix.com
|
|||||||
| Forum | Registrati | Regole Forum | Collegamenti | Album | FAQ | Members List | Calendario | Ricerca | Today's Posts | Mark Forums Read |
| Shell scripting e di programmazione Pubblica domande su KSH, CSH, SH, Bash, Perl, PHP, sed, awk e da altri script di shell e linguaggi di scripting shell qui. |
Più di UNIX e Linux Forum Argomenti potreste trovare utili
|
||||
| Filo | Thread Starter | Forum | Risposte | Ultimo Post |
| Come ieri DATA | osymad | Shell scripting e di programmazione | 19 | 09-23-2009 03:39 PM |
| Aiuto, ho bisogno di avere l'ultima data del mese precedente | sirrtuan | Shell scripting e di programmazione | 11 | 10-14-2008 06:59 AM |
| ultima data di fine mese | vanathi | UNIX e avanzata per utenti esperti | 7 | 03-21-2008 04:17 PM |
| Come mostra la data di ieri | wind_n_cloud | Shell scripting e di programmazione | 1 | 02-16-2005 10:51 PM |
| ottenere data ieri nel formato aaaammgg | hk_newbie | UNIX for Dummies Domande & Risposte | 2 | 12-14-2001 03:32 PM |
![]() |
|
|
LinkBack | Thread Tools | Cerca in questo Thread |
Rating:
|
Modalità di visualizzazione |
|
|
|
||||
|
ieri data mese / giorno
Ciao esperti,
Voglio recuperare ieri su Wikipedia. Come calcolare e assegnare valore della variabile (06/23) in myVariable? #! / bin / sh myVariable \u003d data ieri in mese / data cat / var / adm / sulog | grep $ myVariable> file.txt molte grazie! |
|
||||
|
Non credo che ho. Come controllare?
Sono in grado di ricavare la data, diciamo 24. Ma come fare -1 Come correggere la sintassi di seguito il codice in / 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 aprile | | $ myAnotherMonth \u003d\u003d giugno | | $ myAnotherMonth \u003d\u003d novembre | | $ myAnotherMonth \u003d\u003d febbraio)] allora ieri \u003d 30 elseif [$ myDate \u003d\u003d 1 & & $ myAnotherMonth \u003d\u003d febbraio] ieri \u003d 28 # I dont preoccuparsi di fine mese con 29 altro ieri \u003d $ myDate - 1 fi cat / var / adm / sulog | grep "$ myMonth \ / $ ieri" | grep-v grep> myYear $ $ myMonth $ yesterday_sulog.txt Ultimo a cura di skully; al 06/24/2008 04:28 AM.. |
|
||||
|
Per conoscere la versione di data, Eseguire il mio comando e vedere che cosa la vostra casella di risposta. Una soluzione, ma ancora una volta con GNU data: Codice:
#!/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 non si dispone di GNU data, Provare questo in bash: Codice:
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
Ultimo a cura di ripat; al 06/24/2008 06:39 AM.. Motivo: Ho dimenticato di prendersi cura di gennaio! |
![]() |
| Segnalibri |
| Thread Tools | Cerca in questo Thread |
| Modalità di visualizzazione | Vota questo thread |
|
|