![]() |
Ciao e benvenuto da parte degli Stati Uniti al UNIX e Linux Forum! Grazie per la visita ed unirsi alla nostra Comunità Globale.
|
|
google unix.com
|
|||||||
| Forum | Registrati | Regole Forum | Collegamenti | Album | FAQ | Members List | Calendario | Ricerca | Today's Posts | Mark Forums Read |
| UNIX e avanzata per utenti esperti Expert-to-Expert. Ulteriori avanzata UNIX, comandi UNIX, Linux, Sistemi Operativi, System Administration, Programmazione, Shell, Shell Script, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
Più di UNIX e Linux Forum Argomenti potreste trovare utili
|
||||
| Filo | Thread Starter | Forum | Risposte | Ultimo Post |
| Semplice domanda (per voi ragazzi, difficile per me) | BkontheShell718 | Shell scripting e di programmazione | 3 | 01-07-2008 11:48 AM |
| [domanda] duro esercizio, help needed | EnioMarques | UNIX for Dummies Domande & Risposte | 2 | 09-20-2007 10:22 PM |
| Hard Drive Domanda | Netghost | AIX | 0 | 08-24-2006 01:01 PM |
| Please Help .... Disperato bisogno! Domanda difficile! | Sparticus007 | UNIX e avanzata per utenti esperti | 1 | 01-11-2002 06:43 PM |
| Solo esperti! Hard Domanda Ahead! | Foo49272 | UNIX e avanzata per utenti esperti | 1 | 01-07-2002 10:22 PM |
![]() |
|
|
LinkBack | Thread Tools | Cerca in questo Thread | Rate Thread | Modalità di visualizzazione |
|
|
|
||||
|
domanda difficile
Ho una directory che contiene una serie di file di formato:
A2008001231000.L2 Ho solo la cura circa 6-8 cifre, in modo che i file sono effettivamente: ?????---*. L2 Ho file che variano da 001 *. ????? ????? L2 a 366 *. L2 Va notato questi tre cifre rappresentano il giorno giuliana dei file. Il mio obiettivo è quello di essere in grado di definire due variabili: start_day e end_day. Come faccio fuori elenco di tutti i file tra start_day e end_day. NOTA: Poiché la giuliana giorni deve essere di 3 cifre, che complica le questioni. |
|
||||
|
Vedo che sei in mktime () paradiso.
Da uomo mktime: Codice:
struct tm {
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month */
int tm_mon; /* month */
int tm_year; /* year */
int tm_wday; /* day of the week */
int tm_yday; /* day in the year */
int tm_isdst; /* daylight saving time */
};
tm_yday
The number of days since January 1, in the range 0 to 365.
Codice:
Tsunami julian_days # perl test2.pl Enter start date [yyyy/mm/dd]: 20080101 Enter end date [yyyy/mm/dd]: 20080220 A2008041231000.L2 A2008021231000.L2 A2008001231000.L2 Tsunami julian_days # perl test2.pl Enter start date [yyyy/mm/dd]: 2008/01/01 Enter end date [yyyy/mm/dd]: 2008/02/20 A2008041231000.L2 A2008021231000.L2 A2008001231000.L2 Tsunami julian_days # Codice:
#!/usr/bin/perl -w
use POSIX;
$| = 1;
my $input;
my (@date_s, @date_e);
opendir(DIR, ".") || die "can't opendir: $!";
@dots = grep { ! /^\./ && /\.L2$/ } readdir(DIR);
closedir DIR;
print "Enter start date [yyyy/mm/dd]: ";
($input = <STDIN>) =~ /(\d{4})\/*-*(\d{2})\/*-*(\d{2})/;
$date_s[0] = mktime (0, 0, 0, $3, ($2-1), ($1-1900), 0, 0);
$date_s[2] = $1;
print "Enter end date [yyyy/mm/dd]: ";
($input = <STDIN>) =~ /(\d{4})\/*-*(\d{2})\/*-*(\d{2})/;
$date_e[0] = mktime (0, 0, 0, $3, ($2-1), ($1-1900), 0, 0);
$date_e[2] = $1;
(undef, undef, undef, undef, undef, undef, undef, $date_s[1] ,undef) = localtime($date_s[0]);
(undef, undef, undef, undef, undef, undef, undef, $date_e[1] ,undef) = localtime($date_e[0]);
foreach my $i (@dots)
{
$i =~ /^A(\d{4})(\d{3})/;
print $i . "\n" if (($1 >= $date_s[2] && $1 <= $date_e[2]) && (($2+0) >= $date_s[1] && ($2+0) <= $date_e[1]));
}
|
![]() |
| Segnalibri |
| Tag |
| datecalc |
| Thread Tools | Cerca in questo Thread |
| Modalità di visualizzazione | Vota questo thread |
|
|