perl -F'\h+|[-.:]' -lane '
$h[keys %h]=$F[0] unless $h{$F[0]};
$h{$F[0]}[$_-1] += $F[$_] for 1..$#F}{for ( @h )
{
my @Arefs = map { \$_ } my($days, $hrs, $mins, $secs, $msec) = @{$h{$_}};
while ( $msec >= 1000 ) { $secs++; $msec -= 1000; }
while ( $secs >= 60 ) { $mins++; $secs -= 60; }
while ( $mins >= 60 ) { $hrs++; $mins -= 60; }
while ( $hrs >= 24 ) { $days++; $hrs -= 24; }
print $_, sprintf " %d-%02d:%02d:%02d.%03d", map $$_, @Arefs;
}
' text.file
perl -F'\h+|[-.:]' -lane '
$h[keys %h]=$F[0] unless $h{$F[0]};
$h{$F[0]}[$_-1] += $F[$_] for 1..$#F}{for ( @h )
{
use integer;
my @A = @{$h{$_}};
$A[0] += ($A[1] += ($A[2] += ($A[3] += $A[4]/1000)/60)/60)/24;
$A[4] %= 1000; $A[3] %= 60;$A[2] %= 60; $A[1] %= 24;
print $_, sprintf " %d-%02d:%02d:%02d.%03d", @A;
}
' text_file
aaa 1-21:27:26.255
bbb 5-11:15:04.433
@F
с элементами :$F[0] -> клавиша (aaa/bbb/и т. д. )$F[1] -> дни, $F[2] -> часы, $F[3] -> минуты, $F[4] -> секунды, $F[5] -> миллисекунд. @h
, элементы которого являются хэш-ключами %h
в том порядке, в котором они были просмотрены. %h
составляется следующим образом:%h = (
aaa => [ days, hours, minutes, seconds, milliseconds ],
bbb => [ ... ],
...
);
Взято из systemd System and Service Manager , «ИЗМЕНЕНИЯ С 235»:
nss-myhostname/systemd-resolved will now by default synthesize an A/AAAA resource record for the "_gateway" hostname, pointing to the current default IP gateway. Previously it did that for the "gateway" name, hampering adoption, as some distributions wanted to leave that host name open for local use. The old behaviour may still be requested at build time.
Как видите, некоторые дистрибутивы возражали против использования gateway
в качестве автоматического псевдонима, поэтому он был изменен на _gateway
.
См. также документацию systemd-resolved
, «Синтетические записи».