並び順

ブックマーク数

期間指定

  • から
  • まで

1 - 40 件 / 44件

新着順 人気順

awkの検索結果1 - 40 件 / 44件

  • 35年ぶりの第2版「プログラミング言語AWK 第2版」、オライリーから5月発売

    awkは、UNIX登場初期からgrepやsedなどと並んで代表的なコマンドラインツールとして使われてきました。その名称が、作者であるAho氏、Weinberger氏、Kernighan氏の三者の名前からとったものであるというエピソードも非常に有名です。 そしてこの三人の作者が執筆した書籍「The AWK Programming Language」(邦題:プログラミング言語AWK)は、awkのバイブルと言ってよい書籍でしょう。 日本で1989年に第1版が発行されたこの「プログラミング言語AWK」が、35年ぶりに第2版に改訂され、今年(2024年)5月16日にオライリー・ジャパンから発売されることが分かりました(Amazon、楽天ブックス)。 著者は第1版と変わらず、Alfred V. Aho氏、Brian W. Kernighan氏、Peter J. Weinberger氏です。 下記はAm

      35年ぶりの第2版「プログラミング言語AWK 第2版」、オライリーから5月発売
    • awkが新しくなる!? 本家AwkがUnicode (UTF-8)とCSV対応に! - Qiita

      はじめに 2023年、長い時を経て awk がとうとう Unicode (UTF-8) と CSV に対応しました 🎉🎉🎉 awk で日本語がうまく扱えない(場合がある)、Excel が出力する CSV ファイルが扱えない(場合がある)、といった問題が解決に向けて一歩に進みます。 去年、本家 awk (One True Awk, nawk) に Unicode サポートが Brian Kernighan の手によって追加されたと話題になった(参照)ことを覚えているでしょうか? Brian Kernighan が誰だか知らない方がいるかもしれないので説明すると、オリジナルの awk の開発者の一人で awk の頭文字、Alfred Aho、Peter Weinberger、Brian Kernighan の一人です。通称「K&R」の「プログラミング言語C」や「プログラミング言語AWK」

        awkが新しくなる!? 本家AwkがUnicode (UTF-8)とCSV対応に! - Qiita
      • awkでつくってわかるWebアプリケーション / Web Application Implementation in awk

        YAPC::Hiroshima 2024での、awkによるWebアプリケーションの実装方法について紹介した発表の資料です。 元となった実装は https://github.com/yammerjp/awkblog にあります。 デモアプリケーションは https://awkblog.net にあります。

          awkでつくってわかるWebアプリケーション / Web Application Implementation in awk
        • sed awk make 互換性 つらい うんざりザリガニ - Lambdaカクテル

          仕事でsedのコードをパパッと書いて使ったら、コードレビューで動かんと言われてしまった。そういえば、同僚はMacで、おれはLinuxだったな。 まぁsedならよくある話なので、しょうがないと思ってawkで同じことをした。awkは比較的もうちょっと互換性がある気がしているからだ(どっこいどっこいな気もする)。 しかしまだ動かないと言う。もう、大絶叫だ。アー。おしまいだ。カスがよ〜〜〜と思いつつ(社会人なので絶叫はしない)、よく調べてみるとmakeの互換性だった。というのも、試しにbrew install makeしてGNU Makeで試してみてくれ、と言ったら、あっさり動いたからである。実はsedもawkも悪くなくて、そいつを呼び出してるmakeに互換性がなかった。ごめんな、お前たち悪くなかったよ。でもそれはそうと互換性はない。 define foobarstring ... endef #

            sed awk make 互換性 つらい うんざりザリガニ - Lambdaカクテル
          • Performance comparison: counting words in Python, Go, C++, C, AWK, Forth, and Rust

            Performance comparison: counting words in Python, Go, C++, C, AWK, Forth, and Rust March 2021 Summary: I describe a simple interview problem (counting frequencies of unique words), solve it in various languages, and compare performance across them. For each language, I’ve included a simple, idiomatic solution as well as a more optimized approach via profiling. Go to: Constraints | Python Go C++ C

            • GitHub - djanderson/aho: A git implementation in awk

              $ source ./modpath $ aho init Initialized empty Git repository in .aho $ aho add -v . add '.gitignore' add 'LICENSE' add 'README.md' add 'aho' add 'aho.awk' add 'include/add.awk' add 'include/branches.awk' add 'include/config.awk' [...] $ echo "neat" > testfile $ aho add -v . add 'testfile' $ tree .aho/ .aho/ ├── branches ├── config ├── description ├── HEAD ├── index ├── objects │   ├── 16 │   │  

                GitHub - djanderson/aho: A git implementation in awk
              • jqコマンドのストリーミング処理 (--stream) をパイプでawkにつなぐ方法のまとめ - Qiita

                はじめに 誰もが知っている通り jq コマンドは JSON データを処理するためのフィルタコマンドです。awk コマンドと同じように抽出や編集といったデータ処理を行える専用の言語を備えています。jq コマンドは巨大な JSON データをストリーミングで処理することができる --stream オプションを持っており、データの完全な取得を待たずにデータを受け取りながら処理することが出来ます。しかしその使い方は難しくあまり解説されていません。そこでどのように使うと良いのかを調べてまとめました。 ストリーミング形式の出力 (--stream) まず次のような JSON データを用意しました。 [ {"name": "apple", "price": 210, "count": 10 }, {"name": "banana", "price": 140, "count": 15 }, {"name"

                  jqコマンドのストリーミング処理 (--stream) をパイプでawkにつなぐ方法のまとめ - Qiita
                • The AWK Programming Language, Second Edition

                  Updated Mon Feb 5 10:22:02 EST 2024 Available in paperback and e-book formats. Order at Amazon and other fine booksellers. Introduction This page holds material related to the second edition of The AWK Programming Language. The first edition was written by Al Aho, Brian Kernighan and Peter Weinberger in 1988. Awk has evolved since then, there are multiple implementations, and of course the computi

                  • 問 awk をワンライナーで書く時のアクション区切りの「;」の数は0個? 1個? 2個? + こぼれ話 - Qiita

                    問題 awk で複数のアクションをワンライナーで書いた時、区切りの「;」の数は、0個、1個、2個のうちどれが最も適切でしょうか? 以下の中から適切な回答(複数可)を選び、その理由も答えてください。 # A. セミコロンは不要である echo foo | awk '{print} {print}' # B. セミコロンは一つ必要である echo foo | awk '{print} ; {print}' # C. セミコロンは二つ必要である echo foo | awk '{print} ;; {print}' この記事は上記の問題の回答、およびその回答にまつわる Brian Kernighan と One True Awk、GNU awk との互換性、POSIX awk の標準規格、に関するこぼれ話を紹介する記事です。 . . . ブコメにちゃんと文章読んでるんだろうか?と疑問になるレスが

                      問 awk をワンライナーで書く時のアクション区切りの「;」の数は0個? 1個? 2個? + こぼれ話 - Qiita
                    • プログラミング言語AWK 第2版

                      「AWK」という名前は開発者の頭文字Aho、Weinberger、Kernighanから来たもので、長い歴史を持つ、テキスト処理用のスクリプト言語です。Unix・Linuxにはデフォルトでインストールされており、多くの人に利用され、愛され続けています。改訂に伴い、計算/集計、データ分析といった話題の追加、CSV入力、Unicode対応など、時代に即したアップデートが行われています。 『プログラミング言語AWK』第2版 日本語版まえがき まえがき 1章 Awkチュートリアル 1.1 さあ始めよう 1.2 簡単な表示 1.3 書式付き表示 1.4 選択 1.5 計算 1.6 制御フロー文 1.7 配列 1.8 便利な一行プログラム 1.9 さて次は? 2章 Awkの実践例 2.1 個人用ツール 2.2 選択 2.3 変換 2.4 データ要約 2.5 個人用データベース 2.6 個人用ライブラリ

                        プログラミング言語AWK 第2版
                      • 開発から 45 年、プログラミング言語 AWK に Unicode サポートが追加 | スラド デベロッパー

                        プログラミング言語 AWK が最初に開発された 1977 年から 45 年後の2022年、Brian Kernighan 氏により Unicode サポートが追加されたそうだ (README.unicode、 The Register の記事、 Ars Technica の記事、 Computerphile 動画)。 Kernighan 氏は AWK (Aho Weinberger Kernighan) の「K」の由来でもあるオリジナル開発者で、80 歳になる。GitHub の「The One True Awk」リポジトリに Unicode サポートがコミットされたのは 6 月 1 日だったが、先週 Kernighan 氏が YouTube の Computerphile に出演するまで注目されずにいたようだ。Kernighan 氏によれば、AWK が Unicode をサポートしていない

                        • GitHub - ezrosent/frawk: an efficient awk-like language

                          Note (2024, ezrosent@) While the policy on bugs and feature requests remains unchanged I've had much less time over the last 1-2 years to devote to bug fixes and feature requests for frawk. Other awks are more actively maintained, and CSV support is now a much more common feature in awk compared to when this project started; I'll update this notice if frawk's status changes. frawk is a small progr

                            GitHub - ezrosent/frawk: an efficient awk-like language
                          • AWKGo, an AWK-to-Go compiler

                            November 2021 I’m such a nerd that I nerd-sniped myself. As the author of GoAWK, an AWK interpreter written in Go, I was wondering one day how hard it would be to translate AWK programs into Go code. Couldn’t be that hard, right? I decided to try it. It wasn’t particularly hard – at least, not for the subset of AWK that my compiler supports – and I was able to reuse GoAWK’s parser and many of its

                            • とほほのAWK入門 - とほほのWWW入門

                              「オーク」と呼びます。 開発者の Aho(エイホ)さん、Weinberger(ワインバーガー)さん、Kernighan(カーニハン)さんの頭文字から名前付けされました。 Linux(というかUnix)で古くから(1977年~)サポートされているスクリプト言語です。 Perl(1987年)、Python(1989年)、Ruby(1993年)、PHP(1995年)、JavaScript(1995年)に比べても最古参です。 元々はプログラミング言語というよりは、sed や grep の高機能なツールとして開発されました。 簡単な行ベースのテキストファイルを処理するのに適しています。 大半の Linux にはデフォルトでインストールされています。 実装としては、CentOS 系では高機能な GNU版の gawk、Ubuntu 系ではシンプル・高速な mawk を採用しています。 gawk は「グォ

                              • 世界のプログラミング言語(40) ハッカー御用達の言語AWKはテキスト処理で今日も活躍中

                                歴史の荒波を越えて使い続けられるツールがあります。テキスト処理で使われる歴史あるスクリプト言語AWK(オーク)は間違いなくその一つです。大抵のUNIX/LinuxをはじめmacOSにも最初からインストールされておりWindowsでも使えます。今回は、時代を超えて愛されるスクリプト言語AWKの魅力に迫ってみましょう。 AWKとは AWKは主にテキスト処理に使われるスクリプト言語です。1977年にUNIX開発の過程で生まれました。「AWK」の名前の由来は、開発者のアルフレッド・エイホ、ピーター・ワインバーガー、ブライアン・カーニハンの3人の苗字の頭文字からとられています。 AWK最大の特徴は、CSV形式などのテキストデータを手軽に処理できることです。テキスト処理に特化していることから、簡単なスクリプトを書くだけで、本格的な仕事をこなすことができるのが特徴です。もちろん、汎用的なスクリプト言語と

                                  世界のプログラミング言語(40) ハッカー御用達の言語AWKはテキスト処理で今日も活躍中
                                • GitHub - huijunchen9260/fm.awk: File manager written in awk

                                  NUMBERS: [num] - move cursor to entry [num] [num]+G - Go to page [num] NAVIGATION: k/↑ - up j/↓ - down l/→ - right h/← - left Ctrl-f - Half Page Down Ctrl-u - Half Page Up n/PageDown - PageDown p/PageUp - PageUp g/Home - first page G/End - last page H - first entry L - last entry M - middle entry MODES: / - search : - commandline mode commandline mode special function: {}: represent selected files

                                    GitHub - huijunchen9260/fm.awk: File manager written in awk
                                  • AWK As A Major Systems Programming Language — Revisited

                                    AWK As A Major Systems Programming Language — Revisited Preface I started this paper in 2013, and in 2015 sent it out for review to the people listed later on. After incorporating comments, I sent it to Rik Farrow, the editor of the USENIX magazine ;login: to see if he would publish it. He declined to do so, for reasonably good reasons. The paper languished, forgotten, until early 2018 when I came

                                    • GitHub - rethab/awk-jvm: a toy jvm in awk

                                      You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                        GitHub - rethab/awk-jvm: a toy jvm in awk
                                      • 速習Linux – 文字列の置換・抽出・検索と正規表現【sed・awk・grep】|Yuu's Memo

                                        sedコマンド sed(Stream Editor)は、テキストストリームの編集に特化した強力なツールです。以下にsedコマンドの基本的な構文を示します。 オプション: sedコマンドの挙動を制御するための指定です。例えば、置換を行う場合には-eオプションを使用します。 スクリプト: 実行したいsedコマンドの操作を指定します。置換や削除、追加など、様々な編集操作が可能です。 ファイル名: 処理を行いたいテキストファイルのパスを指定します。省略した場合は標準入力から読み込みます。 以下でもう少し詳しく解説します。 コマンド どういう処理をしたいかをコマンドで指定します。 処理内容の出力、削除、文字列の追加、置換などの処理を行えるコマンドが用意されています。 コマンド説明

                                          速習Linux – 文字列の置換・抽出・検索と正規表現【sed・awk・grep】|Yuu's Memo
                                        • AWK commands equivalent to SQL query - Data manipulation | Page 4 of 4 | Subhadip Mukherjee

                                          Here we are passing two files in awk. You need to understand important part of this command is NR==FNR. NR is the total row number and FNR is the current file row number. Order of file (DEPT.csv EMP.csv) is also important as it controls NR/FNR. So awk will process DEPT.csv first. For this file, NR is equal to FNR for all records. Next file EMP.csv, NR will increase but FNR will be reset to 1 at re

                                            AWK commands equivalent to SQL query - Data manipulation | Page 4 of 4 | Subhadip Mukherjee
                                          • Why Learn AWK? | Jonathan Palardy's Blog

                                            Because of the arcane syntax? Because other languages can’t do the job? No. I resisted AWK for a long time. Couldn’t I already do everything I needed with sed and grep? I felt that anything more complex should be done with a “real” language. AWK seemed like yet-another-thing to learn, with marginal benefits. Why Learn AWK? Let me count the ways. You are working TOO HARD Too many times, I’ve seen p

                                            • awkの正規表現でグループ化とキャプチャ、後方参照を行う - grep Tips *

                                              (正規表現)のように正規表現を()で括ると、マッチした値を参照できるようになる。捕捉グループ、capturing groupと呼ばれ、大体のプログラミング言語の正規表現ライブラリで対応している。 sedだと、\1, \2, ... という記法で後方参照できる。 Rubyだと、正規表現内では \1, \2, ... という記法で後方参照でき、マッチ処理が終わったあとであれば$1, $2, ... という特殊変数によって n 番目の括弧にマッチした文字列を参照できる。 Javaだと、String#replaceAllで置換するなど $1, $2, ... という記法で後方参照でき、Matcherでマッチ処理をする場合はマッチ処理が終わったあとにMatcher#group(int n)で n 番目の括弧にマッチした文字列を参照できる。 Awkでは以下のようにマッチした値を参照する。 awk 'm

                                                awkの正規表現でグループ化とキャプチャ、後方参照を行う - grep Tips *
                                              • The AWK Programming Language, Second Edition

                                                Updated Mon Feb 5 10:22:02 EST 2024 Available in paperback and e-book formats. Order at Amazon and other fine booksellers. Introduction This page holds material related to the second edition of The AWK Programming Language. The first edition was written by Al Aho, Brian Kernighan and Peter Weinberger in 1988. Awk has evolved since then, there are multiple implementations, and of course the computi

                                                • Live Free or Dichotomize - Using AWK and R to parse 25tb

                                                  Using AWK and R to parse 25tb Nick Strayer Jun 4, 2019 27 min read big data awk data cleaning How to read this post: I sincerely apologize for how long and rambling the following text is. To speed up skimming of it for those who have better things to do with their time, I have started most sections with a “Lesson learned” blurb that boils down the takeaway from the following text into a sentence o

                                                  • CSVと親しくなるAWK術 | フューチャー技術ブログ

                                                    はじめにこんにちは、TIG真野です。シェルスクリプト連載の2日目です。 シェルスクリプトなのにAWKってちょっと違うんじゃない?って思われる方も多いと思いますが、この連載におけるレギュレーションではsed, AWKもOKという優しいルール故、見逃しください。 この記事ではCSVデータをAWKで処理する例をいくつか紹介します。 awkとは AWKとはやカンマなどで区切られたテキストデータの処理が得意なスクリプト言語です。awkコマンドはよくawsコマンドとtypoしますが最後はkです。こちらの方が25年くらい歴史があります。 由来はアルフレッド・エイホ、ピーター・ワインバーガー、ブライアン・カーニハンの3人の苗字の頭文で、日本だとオークと呼びます。なんというか由来がレジェンドですね。個人的にはカーニハン先生はプログラミング作法で学んだ過去から、先生の敬称必須です。 awkの基本的な構文はパタ

                                                      CSVと親しくなるAWK術 | フューチャー技術ブログ
                                                    • Understanding AWK

                                                      In this article, we’ll explore the fundamentals of Awk, a tool that simplifies text processing. Earthly streamlines your build processes with ease and effectiveness. Learn more. Background I have a confession to make: I don’t know how to use Awk. Or at least I didn’t know how to use it before I started writing this article. I would hear people mention Awk and how often they used it, and I was pret

                                                        Understanding AWK
                                                      • Unix legend, who owes us nothing, keeps fixing foundational AWK code

                                                        Enlarge / Brian Kernighan speaking at a tribute to his Bell Labs coworker and The C Programming Language co-author Dennis Ritchie in 2012. Ritchie's visage in dominoes is behind Kernighan. A Princeton professor, finding a little time for himself in the summer academic lull, emailed an old friend a couple months ago. Brian Kernighan said hello, asked how their US visit was going, and dropped off hu

                                                          Unix legend, who owes us nothing, keeps fixing foundational AWK code
                                                        • awk とシェルとの値の受け渡しについて - Qiita

                                                          概要 awk への値の受け渡しの記事はよく見かけるが awk からシェルへの値の受け渡しの記事が少ないのでまとめてみた。 シェルから awk への値の受け渡し awk への値の受け渡しは -v オプションを使うと覚えておけば間違いない。 #!/bin/sh # -v オプションで値を手入力 echo | awk -v foo=before '{print foo}' # 実行結果: before # 後ろには書けない echo | awk '{print foo}' -v foo=after # 実行結果: awk: fatal: cannot open file `-v' for reading (No such file or directory) # -v 無しで渡す方法もあるが、BEGINブロックで値を参照できない echo | awk 'BEGIN{print foo} {pri

                                                            awk とシェルとの値の受け渡しについて - Qiita
                                                          • The state of the AWK [LWN.net]

                                                            Please consider subscribing to LWNSubscriptions are the lifeblood of LWN.net. If you appreciate this content and would like to see more of it, your subscription will help to ensure that LWN continues to thrive. Please visit this page to join up and keep LWN on the net. AWK is a text-processing language with a history spanning more than 40 years. It has a POSIX standard, several conforming implemen

                                                            • 初心者のためのawkコマンド - RAKUS Developers Blog | ラクス エンジニアブログ

                                                              はじめに 皆さん初めましてseahoseTです。 今回はLinux上で文字列を処理することに便利なawkについて紹介していきたいと思います。 目次 はじめに awkとは ここがすごいよ!awkのアレコレ! awkの基本的な仕様 awkのコマンド パターン 正規表現 BEGIN,END 評価式 アクション awkの組み込み変数 awkのオプション awkの注意点 問題編:行の指定 解決編:行の指定 問題編:複数のパターンを使用する 解決編:複数のパターンを使用する 問題編:NRとFNR 解決編:NRとFNR 問題編:awkでシェル変数を使用する 解決編:awkでシェル変数を使用する awkの実践 おわりに awkとは AWK(オーク)は、プログラミング言語の一つ。 テキストファイル、特に空白類(スペースの他、タブなど)やカンマなどで区切られたデータファイルの処理を念頭に置いた仕様となっている

                                                                初心者のためのawkコマンド - RAKUS Developers Blog | ラクス エンジニアブログ
                                                              • GitHub - crossbowerbt/awk-webserver: A simple webserver, written in GNU awk, that supports directory listing and download of file from the directory where it is launched

                                                                You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                                                  GitHub - crossbowerbt/awk-webserver: A simple webserver, written in GNU awk, that supports directory listing and download of file from the directory where it is launched
                                                                • GitHub - raygard/wak: wak -- an awk implementation for toybox and standalone

                                                                  You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                                                    GitHub - raygard/wak: wak -- an awk implementation for toybox and standalone
                                                                  • An awk implementation

                                                                    An awk implementation Rob Landley’s toybox project provides a variety of Linux command-line tools, similar to busybox. I have written a compact but fairly complete awk implementation intended to integrate with toybox, but it can also build standalone. This implementation is named wak, because all the good awk names are taken. But when used in toybox, it’s just awk, or toybox awk. wak is coded in C

                                                                    • The AWK book's 60-line version of Make

                                                                      The AWK book’s 60-line version of Make September 2023 Go to: AWK Make | How it works | Python Make | Conclusion In the wonderful book The AWK Programming Language by Aho, Weinberger, and Kernighan, there are a few pages at the end of chapter 7 that present a simplified version of the Make utility – written in a single page of AWK code. Before we look at that, I want to mention that the second edit

                                                                      • awkで列の合計を求める | 俺的備忘録 〜なんかいろいろ〜

                                                                        ちょっとやり方ど忘れしてググった際にうまいこと出てこなかったので、念のため残しておく。日本語って難しいなぁと…。 1.指定した列の合計を求める 特定の列全体の合計を求める場合は、以下のようにforで対象の列を足していく。 例えば2列目の合計のみを求める場合なら、以下のようにコマンドを実行する。 awk '{a+=$2} END{print a;}' ファイルPATH [root@BS-PUB-CENT7-01 tmp]# cat test5.txt 1 2 3 1 2 1 2 2 1 3 1 2 3 1 2 2 2 2 1 2 4 2 2 2 1 2 1 1 1 3 2 2 1 2 2 1 3 2 2 1 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 3 [root@BS-PUB-CENT7-01 tmp]# cat test5.txt | awk '{a+=$2

                                                                        • なぜawkの乱数関数でUnix時間を取得できるのか? ~ 乱数の話とUnix時間の深い関係 - Qiita

                                                                          $ awk 'BEGIN{print srand() + srand()}'; date +%s 1686750469 ← awk コマンドによる出力(1秒ズレている) 1686750468 ← date コマンドによる出力(date コマンドを使った Unix 時間の取得) $ readlink -f $(which awk) # awk の実体は GAWK /usr/bin/gawk このコードは書籍『「シェル芸」に効くAWK処方箋』で紹介されているコードで、「これは強力! AWKとパイプの新しい関係 ~ 時刻を取得する関数、Socket通信、双方向パイプ」や「第2回 月刊『シェルスクリプトマガジン 2014 November (Vol.19)」にも掲載されているようです。一応 Solaris 10.3 / 11.4 の POSIX awk (/usr/xpg4/bin/awk) に限

                                                                            なぜawkの乱数関数でUnix時間を取得できるのか? ~ 乱数の話とUnix時間の深い関係 - Qiita
                                                                          • awkでvlookupみたいな表結合させる - 30歳SIerからWEBエンジニアで奮闘

                                                                            はじめに 最近、bash, awk, jqにお世話になっております。 特にawkは使い始めたばかりなので、awkを使ってワンラインでexcelのvlookup的なことをやりたいときにどうすればよいのかわからなくて、excelで頑張ってたりしてました。 でもエンジニアならば、excelなんて使わなくてもコマンドラインでぱぱっと操作できたほうが格好いいじゃない?と思ったので挑戦してみます。 目標 以下の2つの表を想定する。 ユーザ一覧を格納した表(users.csv) id name -- ---- 1 一郎 2 二郎 3 三郎 4 四郎 何かしらの条件をみたしたIDの表(condition.csv) id -- 2 4 この2つの表から以下を得たい。 ゴール id name condition -- ---- ---- 1 一郎 F 2 二郎 T 3 三郎 F 4 四郎 T conditio

                                                                              awkでvlookupみたいな表結合させる - 30歳SIerからWEBエンジニアで奮闘
                                                                            • awkのmatch()関数の使い方 | ITを使っていこう

                                                                              下記の形式でmatch()を書きます。 対象文字列を先頭から検索し、検索対象が検出された最初の位置を戻り値として返します。 match(対象文字列, 検索対象) ※検索対象は正規表現で指定できる。 match()関数の戻り値 awkのmatch()関数の戻り値は、検索対象が検出された最初の位置を戻り値として返します。 例えば、下記のようにin.txtがあったとします。 $ cat in.txt abc123 abcd123 abcde123123abc123 下記のように、match()関数で"1"が検出された最初の位置をprint出力します。 $ cat sample.awk #!/bin/sh cat in.txt | awk ' { num = match($0, "1") print $0 "は," num "文字目に1が登場します." } ' 下記が実行結果となります。"1"が登

                                                                              • Amazonでプログラミング関連書籍が安い! Kindle本3万点以上が対象のキャンペーン/『独習C++』『独習PHP』は50%OFF、『「シェル芸」に効く!AWK処方箋』が880円【Book Watch/セール情報】

                                                                                  Amazonでプログラミング関連書籍が安い! Kindle本3万点以上が対象のキャンペーン/『独習C++』『独習PHP』は50%OFF、『「シェル芸」に効く!AWK処方箋』が880円【Book Watch/セール情報】
                                                                                • awk(gawk/mawk)でaccesslog内の日付(yyyy/mm/dd HH:MM:SS)にn時間追加したり、フォーマットを変換して出力させる | 俺的備忘録 〜なんかいろいろ〜

                                                                                  Blog 201912 awk(gawk/mawk)でaccesslog内の日付(yyyy/mm/dd HH:MM:SS)にn時間追加したり、フォーマットを変換して出力させる たまにlogを見ながら作業をしたりすることがあるのだけど、そういうときサーバによってはログの日付がGMTで記録されてたりする。 ここは日本であり、やはり自分もJSTで普段生活しているので、いちいち脳内で+9時間して読み取るのはちょっとだるい。できればJSTになってる時刻でログを読みたいところ・・・。 というわけで、取得したログをJSTに変換して出力する方法について考えてみることにした 1. awkで日付を変換する(外部コマンド使用) apacheのログなんかだと、デフォルトでは日付の表記が「28/Nov/2019:09:03:19」のようになってしまっている。 これだとちょっとawkでは扱いづらい面があるため、dat