Как чтобы grep «заблокировать» строки из странного файла

Выход : помогите Прокрутка курсор @MTK упоминает. Обратите внимание, что между zz и z есть разница. .


Прокрутка относительно курсора (scroll-cursor)

Следующие команды перемещают окно редактирования (часть буфера, которая видите), удерживая курсор на той же строке:

z<CR>                   Redraw, line [count] at top of window (default
                        cursor line).  Put cursor at first non-blank in the
                        line.

zt                      Like "z<CR>", but leave the cursor in the same
                        column.  {not in Vi}

z{height}<CR>           Redraw, make window {height} lines tall.  This is
                        useful to make the number of lines small when screen
                        updating is very slow.  Cannot make the height more
                        than the physical screen height.

z.                      Redraw, line [count] at center of window (default
                        cursor line).  Put cursor at first non-blank in the
                        line.

zz                      Like "z.", but leave the cursor in the same column.
                        Careful: If caps-lock is on, this command becomes
                        "ZZ": write buffer and exit!  {not in Vi}

z-                      Redraw, line [count] at bottom of window (default
                        cursor line).  Put cursor at first non-blank in the
                        line.

zb                      Like "z-", but leave the cursor in the same column.
                        {not in Vi}

Горизонтальная прокрутка (scroll-horizontal)

Для следующих четырех команд курсор следует за экраном. Если Персонаж, который курсор включен, перемещается с экрана, курсор перемещается к ближайшему персонажу на экране. Значение «боковой прокрутки» равно не используется.

z<Right>    or
zl                      Move the view on the text [count] characters to the
                        right, thus scroll the text [count] characters to the
                        left.  This only works when 'wrap' is off.  {not in
                        Vi}

z<Left>      or
zh                      Move the view on the text [count] characters to the
                        left, thus scroll the text [count] characters to the
                        right.  This only works when 'wrap' is off.  {not in
                        Vi}

zL                      Move the view on the text half a screenwidth to the
                        right, thus scroll the text half a screenwidth to the
                        left.  This only works when 'wrap' is off.  {not in
                        Vi}

zH                      Move the view on the text half a screenwidth to the
                        left, thus scroll the text half a screenwidth to the
                        right.  This only works when 'wrap' is off.  {not in
                        Vi}

Для следующих двух команд курсор не перемещается в тексте, только текст прокручивается на экране.

zs                      Scroll the text horizontally to position the cursor
                        at the start (left side) of the screen.  This only
                        works when 'wrap' is off.  {not in Vi}

ze                      Scroll the text horizontally to position the cursor
                        at the end (right side) of the screen.  This only
                        works when 'wrap' is off.  {not in Vi}
1
13.04.2016, 23:18
3 ответа

Вероятно, есть более разумный способ сделать все это в awk, но Гвидо на правильном пути, отправив stderr в / dev / null, чтобы избавиться от сообщения 0516-1396 . Вот конвейер, который использует sed для печати только строк между «Logical:» и «Physical», затем снова использует sed для удаления конечной строки «Physical» и удаления текста «Logical:» до этого. использование awk для печати 2-го столбца:

lqueryvg -Atp hdiskpower13 | \
  sed -n '/^Logical:/,/^Physical:/ p' | \
  sed '/^Physical:/d; s/^Logical://' | \
  awk '{print $2}'

Вот решение для всех-awk, которое все еще довольно грубо:

lqueryvg -Atp hdiskpower13 | \
  awk '/^Logical:/,/^Physical/ { 
    if (! /^Physical:/) { 
      gsub("Logical:", "", $0); 
      print $2 }}'
0
28.01.2020, 01:22
for i in prekod prekcf prekre; do lqueryvg -Atp hdiskpower13 | grep $i; done | sed 's/Logical://g' | sed 's/^[ \t]*//;s/[ \t]*$//' | awk '{print $2" "$3}'
0
28.01.2020, 01:22

cut также будет работать, я думаю, и это было бы немного проще, если предположить, что вывод всегда будет одинаковым. Для конкретного вывода, который вы цитировали выше:

grep 'prek*' |cut -w -f3
0
28.01.2020, 01:22

Теги

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