1 / 7

Встроенные переменные

Встроенные переменные. ШАБЛОН. ДЕЙСТВИЕ. { if(FILENAME == ARGV[1]) { ……………………… } }. FILENAME == ARGV[1]) { ……………………… }. getline. - прочитана запись 0 - прочитан EOF -1 - ошибка. { if ((getline tmp) > 0) { print tmp print $0

dougal
Download Presentation

Встроенные переменные

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Встроенные переменные

  2. ШАБЛОН ДЕЙСТВИЕ { if(FILENAME == ARGV[1]) { ……………………… } } FILENAME == ARGV[1]) { ……………………… }

  3. getline • - прочитана запись • 0 - прочитан EOF • -1 - ошибка { if ((getline tmp) > 0) { print tmp print $0 } else print $0 } wan tew free phore tew wan phore free

  4. Встроенные строковые функции awk asort(source [, dest]) - сортировка a["last"] = "de" a["first"] = "sac" a["middle"] = "cul" a["last"] = "de" a["first"] = "sac" a["middle"] = "cul" n = asort( a , b )

  5. Сортировка 1-го массива n =asort(arr) for(i=1; i<=n; i++) print arr[i] Сортировка массива по 2-ой колонке !разные b[i] = $2 i-ая строка массива arr[$2] = $0 запоминаем строку END { n =asort(b) for(i=1; i<=n; i++) print arr[b[i]] }

More Related