⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 walk.awk

📁 awk scripts awk scripts awk scripts awk scripts
💻 AWK
字号:
# from the article:
# "A Walk Through AWK" by Leon S. Levy
# SIGPLAN Notices, V18, #12, December 1983

                                # Prepare a formatted listing of
                                # all occurances of a given keyword
                                # in a file

BEGIN {
        pagesize = 16
        outlines = 0
        NR = -1;
}

outlines % pagesize == 0 && length(lines) != 0 {
                                # new page initialization
                                # print the page header

        printf "\n Pages and lines where AWK occurs\n"
        printf " Page        Lines\n"
        printf " ____        _____\n\n"

        outlines = 6
        newoutpage = 1
}

/AWK/ {                         # if the string "AWK"
                                # occurs in the current record
        occurances++
        pageno = int(NR / 33) + 1
        lineno = (NR % 66) + 1
        if (lines == "") {
                pages = pageno
                lines = lineno
        }
        else if (pages == pageno && length(lines) < 40)
                lines = lines ", " lineno
        else {
                printf "%5d        %s\n",pages, lines
                outlines++
                pages = pageno
                lines = lineno
        }
}
END {
        if (lines != "")
                printf "%5d        %s\n", pages, lines
        printf "\n%d occurances of AWK\n", occurances
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -