![]() |
Olá e boas-vindas de Estados Unidos para o UNIX e Linux Forum! Obrigado por visitar e fazer parte da nossa comunidade global.
|
|
google unix.com
|
|||||||
| Fóruns | Registar | Fórum Regimento | Ligações | Álbuns | FAQ | Lista deputados | Calendário | Pesquisa | Today's Posts | Mark Forums Read |
| UNIX & avançada para usuários experientes Especialista-a-Expert. Saiba avançado UNIX, comandos UNIX, Linux, Sistemas Operativos, Administração de Sistemas, Programação, Shell, shell scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
Mais UNIX e Linux Fórum Tópicos Você pode achar Helpfull
|
||||
| Fio | Thread Starter | Fórum | Respostas | Última postagem |
| Simples questão (para vocês, difícil para mim) | BkontheShell718 | Programação Shell Script e | 3 | 01-07-2008 11:48 |
| [pergunta] duro exercício, ajuda necessária | EnioMarques | UNIX para Dummies Perguntas & Respostas | 2 | 09-20-2007 10:22 |
| Hard Drive Pergunta | Netghost | AIX | 0 | 08-24-2006 01:01 |
| Please Help .... Necessidade desesperada! Hard Pergunta! | Sparticus007 | UNIX & avançada para usuários experientes | 1 | 01-11-2002 06:43 |
| Peritos Apenas! Hard Pergunta Ahead! | Foo49272 | UNIX & avançada para usuários experientes | 1 | 01-07-2002 10:22 |
![]() |
|
|
Linkback | Thread Tools | Pesquisar este Thread | Rate Thread | Display Modes |
|
|
|
||||
|
pergunta difícil
Tenho um diretório que contém uma série de arquivos do formato:
A2008001231000.L2 Só se preocupam com o 6-8 dígitos, de modo que os arquivos sejam efectivamente: ?????---*. L2 Tenho arquivos que vão de 001 ????? ????? *. L2 para 366 *. L2 Note-se estes três dígitos representam o dia do julian ficheiros. O meu objectivo é ser capaz de definir duas variáveis: start_day e end_day. Como posso desligar lista todos os ficheiros entre start_day e end_day. NOTA: Uma vez que o julian dia deve ser de 3 dígitos, isso complica as coisas. |
|
||||
|
Vejo que você está em mktime () paraíso.
Desde o homem mktime: Código:
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.
Código:
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 # Código:
#!/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]));
}
|
![]() |
| Marcadores |
| Tags |
| datecalc |
| Thread Tools | Pesquisar este Thread |
| Display Modes | Esta taxa Thread |
|
|