Кіріспе
Бағдарламалау тілі AWK (/ɔː//k/) — бағдарламалау тілі және Unix сияқты операциялық жүйелердің көпшілігіндегі стандартты мүмкіндік. AWK тілі — деректермен басқарылатын скрипт тілі, мәтіндік деректер ағынына қатысты орындалатын әрекеттер жиынтығынан тұрады. Бұл файлдарда тікелей орындалуы мүмкін немесе мәтінді алу немесе түрлендіру мақсатында құбырдың бөлігі ретінде қолданылуы мүмкін, мысалы, пішімделген есептерді жасау. Тіл кеңінен жолдар дерек типін, ассоциативтік массивтерді (яғни, кілттік жолдармен индексацияланған массивтерді) және тұрақты өрнектерді пайдаланады. AWK шектеулі қолданыс саласына ие және біржолғы бағдарламаларды қолдау үшін әсіресе жасалған болса да, тіл Тьюринг толық және тіпті AWK-ның алғашқы Bell Labs қолданушылары көбінесе жақсы құрылымдалған үлкен AWK бағдарламаларын жазды. AWK 1970-ші жылдары Bell Labs-те құрылды, ал оның атауы авторларының тегінен шыққан: Альфред Ахо (egrep авторы), Питер Вайнбергер (кішкентай реляциялық деректер базаларында жұмыс істеген) және Брайан Керниган. Акроним AWK бағдарламалау тілінің мұқабасында бейнеленген құс түрінің атауымен бірдей айтылады. 7-ші Unix нұсқасында пайда болған алғашқы құралдардың бірі ретінде AWK, стандартты Unix ортасында қол жетімді жалғыз скрипт тілі — Bourne shell-ден басқа Unix құбыр желісіне есептеу мүмкіндіктерін қосты. Бұл Single UNIX Specification-тің міндетті құралдарының бірі және Linux Standard Base спецификациясымен талап етіледі. 1983 жылы AWK, Bell Laboratories лицензиясы бойынша Charles River Data Systems-тің UNOS операциялық жүйесі үшін қол жетімді бірнеше UNIX құралдарының бірі болды. AWK 1985–88 жылдары айтарлықтай қайта қаралып, кеңейтілді, нәтижесінде Пол Рубин, Джей Фенласон және Ричард Столлман жазған GNU AWK іске асырылуы 1988 жылы жарық көрді. GNU AWK 1994 жылдан бері тек Арнольд Роббинспен күтіліп келеді. Брайан Керниганның nawk (New AWK) бастапқы коды алғаш рет 1993 жылы жарияланбастан шығарылды және 1990-дардың соңынан бері көпшілікке жарияланды; көптеген BSD жүйелері GPL лицензиясынан қашу үшін оны пайдаланады. AWK бағдарламасы — бұл үлгі-әрекет жұптарының тізімі, келесідей жазылған:
the programming language
AWK (/ɔː//k/ and is a standard feature of most Unix like operating systems. The AWK language is a data driven scripting language consisting of a set of actions to be taken against streams of textual data – either run directly on files or used as part of a pipeline – for purposes of extracting or transforming text, such as producing formatted reports. The language extensively uses the string datatype, associative arrays (that is, arrays indexed by key strings), and regular expressions. While AWK has a limited intended application domain and was especially designed to support one liner programs, the language is Turing complete, and even the early Bell Labs users of AWK often wrote well structured large AWK programs. AWK was created at Bell Labs in the 1970s, and its name is derived from the surnames of its authors: Alfred Aho (author of egrep), Peter Weinberger (who worked on tiny relational databases), and Brian Kernighan. The acronym is pronounced the same as the name of the bird species auk, which is illustrated on the cover of The AWK Programming Language. As one of the early tools to appear in Version 7 Unix, AWK added computational features to a Unix pipeline besides the Bourne shell, the only scripting language available in a standard Unix environment. It is one of the mandatory utilities of the Single UNIX Specification, and is required by the Linux Standard Base specification. In 1983, AWK was one of several UNIX tools available for Charles River Data Systems' UNOS operating system under Bell Laboratories license. AWK was significantly revised and expanded in 1985–88, resulting in the GNU AWK implementation written by Paul Rubin, Jay Fenlason, and Richard Stallman, released in 1988. because it is included with GNU based Linux packages. GNU AWK has been maintained solely by Arnold Robbins since 1994. Brian Kernighan's nawk (New AWK) source was first released in 1993 unpublicized, and publicly since the late 1990s; many BSD systems use it to avoid the GPL license. An AWK program is a series of pattern action pairs, written as:
condition { action }
condition { action }
where condition is typically an expression and action is a series of commands. The input is split into records, where by default records are separated by newline characters so that the input is split into lines. The program tests each record against each of the conditions in turn, and executes the action for each expression that is true. Either the condition or the action may be omitted. The condition defaults to matching every record. The default action is to print the record. This is the same pattern action structure as sed. In addition to a simple AWK expression, such as foo == 1 or /^foo/, the condition can be BEGIN or END causing the action to be executed before or after all records have been read, or pattern1, pattern2 which matches the range of records starting with a record that matches pattern1 up to and including the record that matches pattern2 before again trying to match against pattern1 on subsequent lines. In addition to normal arithmetic and logical operators, AWK expressions include the tilde operator, ~, which matches a regular expression against a string. As handy syntactic sugar, /regexp/ without using the tilde operator matches against the current record; this syntax derives from sed, which in turn inherited it from the ed editor, where / is used for searching. This syntax of using slashes as delimiters for regular expressions was subsequently adopted by Perl and ECMAScript, and is now common. The tilde operator was also adopted by Perl.
condition { action }
condition { action }
the programming language
AWK (/ɔː//k/ and is a standard feature of most Unix like operating systems. The AWK language is a data driven scripting language consisting of a set of actions to be taken against streams of textual data – either run directly on files or used as part of a pipeline – for purposes of extracting or transforming text, such as producing formatted reports. The language extensively uses the string datatype, associative arrays (that is, arrays indexed by key strings), and regular expressions. While AWK has a limited intended application domain and was especially designed to support one liner programs, the language is Turing complete, and even the early Bell Labs users of AWK often wrote well structured large AWK programs. AWK was created at Bell Labs in the 1970s, and its name is derived from the surnames of its authors: Alfred Aho (author of egrep), Peter Weinberger (who worked on tiny relational databases), and Brian Kernighan. The acronym is pronounced the same as the name of the bird species auk, which is illustrated on the cover of The AWK Programming Language. As one of the early tools to appear in Version 7 Unix, AWK added computational features to a Unix pipeline besides the Bourne shell, the only scripting language available in a standard Unix environment. It is one of the mandatory utilities of the Single UNIX Specification, and is required by the Linux Standard Base specification. In 1983, AWK was one of several UNIX tools available for Charles River Data Systems' UNOS operating system under Bell Laboratories license. AWK was significantly revised and expanded in 1985–88, resulting in the GNU AWK implementation written by Paul Rubin, Jay Fenlason, and Richard Stallman, released in 1988. because it is included with GNU based Linux packages. GNU AWK has been maintained solely by Arnold Robbins since 1994. Brian Kernighan's nawk (New AWK) source was first released in 1993 unpublicized, and publicly since the late 1990s; many BSD systems use it to avoid the GPL license. An AWK program is a series of pattern action pairs, written as:
condition { action }
condition { action }
where condition is typically an expression and action is a series of commands. The input is split into records, where by default records are separated by newline characters so that the input is split into lines. The program tests each record against each of the conditions in turn, and executes the action for each expression that is true. Either the condition or the action may be omitted. The condition defaults to matching every record. The default action is to print the record. This is the same pattern action structure as sed. In addition to a simple AWK expression, such as foo == 1 or /^foo/, the condition can be BEGIN or END causing the action to be executed before or after all records have been read, or pattern1, pattern2 which matches the range of records starting with a record that matches pattern1 up to and including the record that matches pattern2 before again trying to match against pattern1 on subsequent lines. In addition to normal arithmetic and logical operators, AWK expressions include the tilde operator, ~, which matches a regular expression against a string. As handy syntactic sugar, /regexp/ without using the tilde operator matches against the current record; this syntax derives from sed, which in turn inherited it from the ed editor, where / is used for searching. This syntax of using slashes as delimiters for regular expressions was subsequently adopted by Perl and ECMAScript, and is now common. The tilde operator was also adopted by Perl.
мұнда condition әдетте өрнек, ал action — командалар тізімі. Кіріс жазбаларға бөлінеді, әдепкі бойынша жазбалар жаңа жол таңбаларымен бөлінеді, сондықтан кіріс жолдарға бөлінеді. Бағдарлама әр жазбаны әрбір condition-мен салыстырып, әрбір дұрыс өрнек үшін action-ды орындайды. Condition немесе action алынып тасталуы мүмкін. Condition әдепкі бойынша әрбір жазбаға сәйкес келеді. Әдепкі action — жазбаны басып шығару. Бұл sed-тегідей бірдей үлгі-әрекет құрылымы. Foo == 1 немесе /^foo/ сияқты қарапайым AWK өрнегінен басқа, condition BEGIN немесе END болуы мүмкін, бұл барлық жазбалар оқылғаннан бұрын немесе кейін action-ды орындауға мүмкіндік береді, немесе pattern1, pattern2, бұл pattern1-ге сәйкес келетін жазбадан бастап pattern2-ге сәйкес келетін жазбаға дейін жазбалар диапазонына сәйкес келеді, содан кейін келесі жолдарда pattern1-ге сәйкес келуге тырысады. Қарапайым арифметикалық және логикалық операторлардан басқа, AWK өрнектері тұрақты өрнекті жолмен сәйкестіретін tilde операторын (~ ) қамтиды. Құлайтын синтаксистік қант ретінде /regexp/ тильда операторын пайдаланбастан ағымдағы жазбаға сәйкес келеді; бұл синтаксис sed-ден алынған, ол өз кезегінде оны ed редакторынан мұра еткен, онда / іздеу үшін қолданылады. Регламенттік өрнектерді бөлу үшін кескіштерді пайдаланудың бұл синтаксисі кейіннен Perl және ECMAScript қабылдады және қазір кең таралған. Tilde операторы да Perl-де қабылданды.
the programming language
AWK (/ɔː//k/ and is a standard feature of most Unix like operating systems. The AWK language is a data driven scripting language consisting of a set of actions to be taken against streams of textual data – either run directly on files or used as part of a pipeline – for purposes of extracting or transforming text, such as producing formatted reports. The language extensively uses the string datatype, associative arrays (that is, arrays indexed by key strings), and regular expressions. While AWK has a limited intended application domain and was especially designed to support one liner programs, the language is Turing complete, and even the early Bell Labs users of AWK often wrote well structured large AWK programs. AWK was created at Bell Labs in the 1970s, and its name is derived from the surnames of its authors: Alfred Aho (author of egrep), Peter Weinberger (who worked on tiny relational databases), and Brian Kernighan. The acronym is pronounced the same as the name of the bird species auk, which is illustrated on the cover of The AWK Programming Language. As one of the early tools to appear in Version 7 Unix, AWK added computational features to a Unix pipeline besides the Bourne shell, the only scripting language available in a standard Unix environment. It is one of the mandatory utilities of the Single UNIX Specification, and is required by the Linux Standard Base specification. In 1983, AWK was one of several UNIX tools available for Charles River Data Systems' UNOS operating system under Bell Laboratories license. AWK was significantly revised and expanded in 1985–88, resulting in the GNU AWK implementation written by Paul Rubin, Jay Fenlason, and Richard Stallman, released in 1988. because it is included with GNU based Linux packages. GNU AWK has been maintained solely by Arnold Robbins since 1994. Brian Kernighan's nawk (New AWK) source was first released in 1993 unpublicized, and publicly since the late 1990s; many BSD systems use it to avoid the GPL license. An AWK program is a series of pattern action pairs, written as:
condition { action }
condition { action }
where condition is typically an expression and action is a series of commands. The input is split into records, where by default records are separated by newline characters so that the input is split into lines. The program tests each record against each of the conditions in turn, and executes the action for each expression that is true. Either the condition or the action may be omitted. The condition defaults to matching every record. The default action is to print the record. This is the same pattern action structure as sed. In addition to a simple AWK expression, such as foo == 1 or /^foo/, the condition can be BEGIN or END causing the action to be executed before or after all records have been read, or pattern1, pattern2 which matches the range of records starting with a record that matches pattern1 up to and including the record that matches pattern2 before again trying to match against pattern1 on subsequent lines. In addition to normal arithmetic and logical operators, AWK expressions include the tilde operator, ~, which matches a regular expression against a string. As handy syntactic sugar, /regexp/ without using the tilde operator matches against the current record; this syntax derives from sed, which in turn inherited it from the ed editor, where / is used for searching. This syntax of using slashes as delimiters for regular expressions was subsequently adopted by Perl and ECMAScript, and is now common. The tilde operator was also adopted by Perl.
Командалар
AWK командалары – жоғарыдағы мысалдарда әрекет орнына қойылатын операторлар. AWK командалары функцияларды шақыру, айнымалыларға мән беру, есептеулер жасау немесе олардың кез келген комбинациясын қамтуы мүмкін. AWK көптеген функцияларды қолдауға ендірілген; ал көптеген басқалары AWK-ның түрлі нұсқаларында ұсынылады. Сонымен қатар, кейбір нұсқалары динамикалық байланысты кітапханаларды қосуды қолдайды, олар артық функцияларды ұсынуы мүмкін.