Страница 1 из 1

Добавить : через два символа

Добавлено: 2009-03-21 10:32:17
RusBiT
Читал man sed , не нашел ответа
Нужно преобразовать 0019db24f4c0 в 00:19:db:24:f4:c0

Re: Добавить : через два символа

Добавлено: 2009-03-21 11:13:04
Гость
RusBiT писал(а):Читал man sed , не нашел ответа
не то читал, нужно либо re_format(7) либо `info regex'
re_format(7) писал(а): A bound is `{' followed by an unsigned decimal integer, possibly followed
by `,' possibly followed by another unsigned decimal integer, always fol-
lowed by `}'. The integers must lie between 0 and RE_DUP_MAX (255#)
inclusive, and if there are two of them, the first may not exceed the
second. An atom followed by a bound containing one integer i and no
comma matches a sequence of exactly i matches of the atom. An atom fol-
lowed by a bound containing one integer i and a comma matches a sequence
of i or more matches of the atom. An atom followed by a bound containing
two integers i and j matches a sequence of i through j (inclusive)
matches of the atom.
RusBiT писал(а):Нужно преобразовать 0019db24f4c0 в 00:19:db:24:f4:c0

Код: Выделить всё

$ echo 0019db24f4c0 | sed 's|.\{2\}|&:|g; s|:$||'

Re: Добавить : через два символа

Добавлено: 2009-03-21 12:47:52
RusBiT
Спасиб!

Re: Добавить : через два символа

Добавлено: 2009-09-27 17:47:04
RusBiT
на perl

Код: Выделить всё

$mac=join ":",$mac =~ /.{2}/g;