The UNIX and Linux Forums  

Go Back   UNIX e Linux Forum > Inizio Forum > Shell scripting e di programmazione
.
google unix.com



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
calcolare 13 mesi fa andrea_mussap Shell scripting e di programmazione 4 11-21-2007 08:14 PM
Cron di eseguire primo giorno del mese per il calcolo della data 3 mesi fa new2ss Shell scripting e di programmazione 1 05-17-2007 03:28 AM
alcuni mesi ego big123456 Shell scripting e di programmazione 8 07-27-2005 04:31 AM
Confrontare due mesi pankschawla UNIX e avanzata per utenti esperti 1 02-11-2004 07:32 AM
DNS Aiuto - State cercando di fare per questo mese matt2kjones Reti IP 16 09-28-2002 10:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Cerca in questo Thread Rate Thread Modalità di visualizzazione
  #1 (permalink)  
Old 11-16-2007
andrea_mussap andrea_mussap is offline
Utente Registrato
  
 

Iscriviti Data: novembre 2007
Interventi: 4
calcolare 13 mesi fa

salve,
Ho un grosso file che contiene i dati dal 4 anni fa.

Ho bisogno di ri-creare il file, ma solo le righe che sono 13 mesi fa da oggi.

vedere quello che ho: (Ho un file.ksh che chiama questo file.scl ok!)

\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d File.scl \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d
/ STATISTICHE stderr \u003d
/ STABILE
/ NODUPLICATES
/ EXECUTE "oggi \u003d` date +% Y% m% d `"
/ EXECUTE "13m_ago \u003d` expr $ () oggi - 10000 `"
/ Infile \u003d $ PAR_SCL1
/ SETTORE \u003d (CONTA_CORRENTE, POSIZIONE \u003d 1, SIZE \u003d 13)
/ SETTORE \u003d (DATA_VENCIMENTO, POSIZIONE \u003d 50, SIZE \u003d 10)
/ CONDIZIONI \u003d (cond1, TEST \u003d (DATA_VENCIMENTO> ($ 13m_ago))
/ Include \u003d (\u003d cond1 CONDIZIONE)
/ KEY \u003d (NUMERO_FATURA, ASCENDENTE)
/ OUTFILE \u003d $ PAR_SCL2
/ SETTORE \u003d (CONTA_CORRENTE, POSIZIONE \u003d 1, SIZE \u003d 13)
/ SETTORE \u003d (DATA_VENCIMENTO, POSIZIONE \u003d 50, SIZE \u003d 10)

\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u0

"DATA_VENCIMENTO" è la data che deve essere pari al massimo 13 mesi fa.
il layout del DATA_VENCIMENTO è 20071115, per esempio.


Ho già vedere l'argomento ( Data di ieri / Data aritmetici), Ma non mi aiuta ...

Il mio è l'unico Unix Solaris.

qualcuno non può aiutare?
grazie, Andrea.
  #2 (permalink)  
Old 11-16-2007
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Ubicazione: Ashburn, Virginia
Messaggi: 9.125
Codice:
$ cat 13months_ago
#! /usr/bin/ksh

for input in 20071115 20071105 20070105 ; do

        year=${input%????}
        day=${input#??????}
        month=${input#????}
        month=${month%??}
        month=${month#0}
        day=${day#0}
        print -n $input $year $month $day

        ((year=year-1))
        ((month=month-1))
        if ((!month)) ; then
                ((year=year-1))
                month=12
        fi
        typeset -Z2 newday newmonth
        newday=$day
        newmonth=$month
        output=${year}${newmonth}${newday}
        print -- " -->" $year $month $day $output
done
exit 0
$ ./13months_ago
20071115 2007 11 15 --> 2006 10 15 20061015
20071105 2007 11 5 --> 2006 10 5 20061005
20070105 2007 1 5 --> 2005 12 5 20051205
$
  #3 (permalink)  
Old 11-16-2007
andrea_mussap andrea_mussap is offline
Utente Registrato
  
 

Iscriviti Data: novembre 2007
Interventi: 4
re.: calcolare 13 mesi fa

Perderabo, grazie, ma il suo esempio non funziona per me.

ma ho trovato la soluzione:

nel mio programma principale calcolare 13 mesi fa

oggi \u003d `date +% Y% m% d`
data_13m \u003d `expr $ () oggi - 10200»

e poi, ho inviare la variabile data_13m al file.scl

esportazione PAR_SCL3 \u003d $ () data_13m

nel file.scl ho fatto:

.
.
/ EXECUTE "$ PAR_SCL3"
/ Infile \u003d $ PAR_SCL1
/ SETTORE \u003d (CONTA_CORRENTE, POSIZIONE \u003d 1, SIZE \u003d 13)
/ SETTORE \u003d (DATA_VENCIMENTO, POSIZIONE \u003d 50, SIZE \u003d 10)
/ CONDIZIONI \u003d (cond1, TEST \u003d (DATA_VENCIMENTO> $ PAR_SCL3))

e ha funzionato!
di.
  #4 (permalink)  
Old 11-16-2007
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Ubicazione: Ashburn, Virginia
Messaggi: 9.125
Sei in vigore sottraendo 1 anno e 2 mesi a decorrere dalla data. Se questa è la tua definizione di "13 mesi fa", si potrebbe cambiare il mio script
((mese \u003d mese-2))
if ((mese <1)); poi

Notare che il metodo non se la data originale è in gennaio o febbraio.
Closed Thread

Segnalibri

Thread Tools Cerca in questo Thread
Cerca in questo Thread:

Ricerca Avanzata
Modalità di visualizzazione Vota questo thread
Vota questo thread:

Distacco regolamento
Tu non può post nuovo thread
Tu non può inviare una risposta
Tu non può postare allegati
Tu non può modificare i tuoi post

BB codice è Su
Smilies sono Su
[IMG] codice Su
Codice HTML è Chiuso
Trackbacks sono Su
Pingbacks sono Su
Refbacks sono Su




Tutti gli orari sono GMT -4. La data di oggi è 11:46 AM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Traduzioni Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
UNIX e Linux Forum Content Copyright © 1993-2009. Tutti i diritti Reserved.Ad di gestione da RedTyger

Contenuti pertinenti URL da vBSEO 3.2.0