kvm использовать все дисковое устройство

Мы записываем точки / число, когда встречаемся с соответствующей строкой. Параметр -p будет автоматически печатать строк. Когда мы достигаем eof , мы извлекаем хэш % h и передаем его через фильтр grep , чтобы определить, какие терминалы не печатали, и используем map , чтобы подготовить формат для этого.

perl -lpe 'm|^pts/([0-9])$| and $h{$1}++;
   END{ print for map { "pts/$_" } grep { !$h{$_} } 0 .. 9; }
' /etc/securetty

Мы инициализируем удерживаемое пространство числами 0 1 2 ... 9. Когда мы встречаем строку pts / [0-9] , мы вырезаем это из удерживаемого пространства. . В eof мы получаем удерживаемое пространство, и если какие-либо числа будут найдены, они будут преобразованы в надлежащий формат и распечатаны.

sed -e '
   # initialize the hold space with 0 1 ... 9
   1{x;s|.*|'"$(echo {0..9})"'|;x}

   # whatever be the line, it needs to be printed
   p

   # we meet a valid pts/ line
   \|^pts/[0-9]$|{
      # the hold space gets appended to the pattern space
      G
      # grab what is the pts number and search for it in the hold and
      # delete itand store back the changes into hold space.
      s|^pts/\([0-9]\)\n\(.*\)\1 |\2|;h
   }

   # weve not arrived at the eof and weve processed the input so go no further
   $!d

   # we are at the eof, so we bring back the hold space. just in case all
   # numbers were dealt with up, we simply bail out. Else, prepend the str 
   # pts/ to the numbers present and simply were home
   g;/[0-9]/!d;s/ //g
   s|[0-9]|pts/&\n|g;s/.$//

   # *TIP*: Sprinkle the l, list pattern space at various places to see 
   # whats going on.

' /etc/securetty 
1
05.07.2019, 02:25
0 ответов

Теги

Похожие вопросы