Coder Social home page Coder Social logo

seanpm2001 / learn-awk Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 439 KB

A repository for showcasing my knowledge of the Awk programming language, and continuing to learn the language.

Home Page: https://github.com/seanpm2001/Learn/

License: GNU General Public License v3.0

Awk 100.00%
article awk awk-language collection gpl3 gplv3 knowledge learn learn-awk md

learn-awk's Introduction


/The-AWK-Programming-Language.svg

Learning AWK (programming language)

I know very little about the AWK programming language. This document will go over all of my knowledge of the AWK programming language.

Hello World in AWK

This is how you make a Hello World program in AWK:

BEGIN {
        print "Hello, world!"
        exit
}

Comments in AWK

Comments in AWK are the same as in Shell.

Single line comments

Single line comments in AWK are written like so:

# This is a single line comment
Multi-line comments

I don't know if AWK supports multi-line comments.

Break keyword in AWK

break

To this day, I am still not entirely sure what the break keyword does, but most languages support it.

/!\ This example has not been tested yet, and may not work

REGEX patterns in AWK

AWK supports REGEX (Regular Expression) patterns. They can be implemented like so:

/regex_pattern/ {
    # Actions to perform in the event the record (line) matches the above regex_pattern
    print 3+2
    print foobar(3)
    print foobar(variable)
    print sin(3-2)
}

The output can then be sent to a file directly

/regex_pattern/ {
    # Actions to perform in the event the record (line) matches the above regex_pattern
    print "expression" > "file name"
}

or through a pipe |

/regex_pattern/ {
    # Actions to perform in the event the record (line) matches the above regex_pattern
    print "expression" | "command"
}

These examples were taken directly from Wikipedia, and modified to fit how I interpret it.

/!\ This example has not been tested yet, and may not work

Other knowledge of the AWK programming language

  1. AWK is a language by Alfred Aho, Peter Weinberger, and Brian Kernighan, of which the language is named after the first letter of their last names (AWK)

  2. AWK is not a semicolon and curly bracket language, but it is a curly bracket language

  3. AWK uses the *.awk file extension by default

  4. AWK is a functional programming language

  5. AWK is one of the default scripting languages in most UNIX/POSIX operating systems, such as Linux and BSD

  6. AWK is one of the top 50 programming languages (as of 2022, July 31st, ranking #41)

  7. AWK was first created in the year 1977

  8. No other knowledge of the AWK programming language

Additional comments

  1. I have not yet memorized the names of the developers

  2. No other additional comments available


File info

File type: Markdown document (*.md *.mkd *.mdown *.markdown)

File version: 1 (2022, Monday, August 1st at 5:08 pm PST)

Line count (including blank lines and compiler line): 158


File history

Click/tap here to expand/collapse the history for this file

Version 1 (2022, Monday, August 1st at 5:08 pm PST)

Changes:

  • Started the file
  • Added the title section
  • Added the Hello World in AWK section
  • Added the Comments in AWK section
  • Added the Single line comments subsection
  • Added the Multi-line comments subsection
  • Added the break keyword in AWK section
  • Added the REGEX patterns in AWK section
  • Added the other knowledge of the AWK programming language section
  • Added the Additional comments section
  • Added the file info section
  • Added the file history section
  • No other changes in version 1

learn-awk's People

Contributors

seanpm2001 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

seanwallawalla

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.