Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3124190

Browse files
updates for version 1.3
1 parent 47b84c2 commit 3124190

File tree

12 files changed

+136
-104
lines changed

12 files changed

+136
-104
lines changed

‎README.md‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ You can purchase the book using these links:
2121
* https://gumroad.com/l/gnu_awk
2222
* https://leanpub.com/gnu_awk
2323
* You can also get the book as part of **Magical one-liners** bundle from https://gumroad.com/l/oneliners or https://leanpub.com/b/oneliners
24-
* You can also get the book as part of **Awesome Regex** bundle from https://leanpub.com/b/regex or https://gumroad.com/l/regex
24+
* You can also get the book as part of **Awesome Regex** bundle from https://gumroad.com/l/regex or https://leanpub.com/b/regex
2525
* See https://learnbyexample.github.io/books/ for list of other books
2626

27-
For a preview of the book, see [sample chapters](https://github.com/learnbyexample/learn_gnuawk/blob/master/sample_chapters/awk_sample_chapters.pdf)
27+
For a preview of the book, see [sample chapters](https://github.com/learnbyexample/learn_gnuawk/blob/master/sample_chapters/gnu_awk_sample.pdf)
2828

2929
The book can also be [viewed as a single markdown file in this repo](./gnu_awk.md). See my blogpost on [generating pdf from markdown using pandoc](https://learnbyexample.github.io/tutorial/ebook-generation/customizing-pandoc/) if you are interested in the ebook creation process.
3030

@@ -34,11 +34,11 @@ For web version of the book, visit https://learnbyexample.github.io/learn_gnuawk
3434

3535
# Feedback
3636

37-
Please open an issue if you spot any typo/errors.
37+
[Open an issue](https://github.com/learnbyexample/learn_gnuawk/issues) if you spot any typo/errors.
3838

39-
I'd also highly appreciate your feedback about the book.
39+
:warning::warning: Please DO NOT submit pull requests. Main reason being any modification requires changes in multiple places.
4040

41-
Goodreads: https://www.goodreads.com/book/show/52758608-gnu-awk
41+
I'd also highly appreciate your feedback about the book.
4242

4343
Twitter: https://twitter.com/learn_byexample
4444

@@ -70,8 +70,9 @@ Twitter: https://twitter.com/learn_byexample
7070

7171
* [GNU awk documentation](https://www.gnu.org/software/gawk/manual/) — manual and examples
7272
* [stackoverflow](https://stackoverflow.com/) and [unix.stackexchange](https://unix.stackexchange.com/) — for getting answers to pertinent questions on `bash`, `awk` and other commands
73-
* [tex.stackexchange](https://tex.stackexchange.com/) — for help on `pandoc` and `tex` related questions
74-
* Cover image: [LibreOffice Draw](https://www.libreoffice.org/discover/draw/)
73+
* [tex.stackexchange](https://tex.stackexchange.com/) — for help on [pandoc](https://github.com/jgm/pandoc/) and `tex` related questions
74+
* [LibreOffice Draw](https://www.libreoffice.org/discover/draw/) — cover image
75+
* [pngquant](https://pngquant.org/) and [svgcleaner](https://github.com/RazrFalcon/svgcleaner) for optimizing images
7576
* [softwareengineering.stackexchange](https://softwareengineering.stackexchange.com/questions/39/whats-your-favourite-quote-about-programming) and [skolakoda](https://skolakoda.org/programming-quotes) for programming quotes
7677
* [Warning](https://commons.wikimedia.org/wiki/File:Warning_icon.svg) and [Info](https://commons.wikimedia.org/wiki/File:Info_icon_002.svg) icons by [Amada44](https://commons.wikimedia.org/wiki/User:Amada44) under public domain
7778
* [arifmahmudrana](https://github.com/arifmahmudrana) for spotting an ambiguous explanation
@@ -88,3 +89,4 @@ Special thanks to all my friends and online acquaintances for their help, suppor
8889
The book is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/)
8990

9091
The code snippets are licensed under MIT, see [LICENSE](./LICENSE) file
92+

‎Version_changes.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<br>
22

3+
### 1.3
4+
5+
* Added note regarding use of `NR==FNR` if the first file is empty
6+
* Added note for `split` function when the field separator is the same as default `FS`
7+
* Simplified one of the examples for paragraph mode
8+
* Updated exercise solutions as well for this usecase
9+
* Updated timing data for speed comparison examples, added `mawk` results as well
10+
* Corrected various typos, improved descriptions, comments, external links, etc
11+
12+
<br>
13+
314
### 1.2
415

516
* Added link to exercise solutions

‎code_snippets/Field_separators.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ echo 'goal:amazing:whistle:kwality' | awk -F: '{print $NF}'
3838

3939
echo 'one;two;three;four' | awk -F';' '{print 3ドル}'
4040

41-
echo '=a=b=c=' | awk -F= '{print 1ドル "," $NF "."}'
41+
echo '=a=b=c=' | awk -F= '{print 1ドル "[" $NF "]"}'
4242

4343
echo 'goal:amazing:whistle:kwality' | awk -v FS=: '{print 2ドル}'
4444

‎code_snippets/Gotchas_and_Tips.sh‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,17 @@ time awk '/^([a-d][r-z]){3}$/' /usr/share/dict/words > f1
8888

8989
time LC_ALL=C awk '/^([a-d][r-z]){3}$/' /usr/share/dict/words > f2
9090

91+
time mawk '/^[a-d][r-z][a-d][r-z][a-d][r-z]$/' /usr/share/dict/words > f3
92+
9193
diff -s f1 f2
9294

93-
rm f[12]
95+
diff -s f2 f3
96+
97+
rm f[123]
9498

9599
time awk -F'a' 'NF==4{cnt++} END{print +cnt}' /usr/share/dict/words
96100

97101
time LC_ALL=C awk -F'a' 'NF==4{cnt++} END{print +cnt}' /usr/share/dict/words
98102

103+
time mawk -F'a' 'NF==4{cnt++} END{print +cnt}' /usr/share/dict/words
104+

‎code_snippets/Installation_and_Documentation.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tar -Jxf gawk-5.1.0.tar.xz
66

77
cd gawk-5.1.0/
88

9-
./configure
9+
./configure
1010

1111
make
1212

‎code_snippets/Record_separators.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cat programming_quotes.txt
4848

4949
awk -v RS= -v ORS='\n\n' '/you/' programming_quotes.txt
5050

51-
awk -v RS= '/you/{print c++ ? "\n" 0ドル : 0ドル}' programming_quotes.txt
51+
awk -v RS= '/you/{print s 0ドル; s="\n"}' programming_quotes.txt
5252

5353
s='\n\n\na\nb\n\n12\n34\n\nhi\nhello\n'
5454

‎code_snippets/Regular_Expressions.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
printf 'spared no one\ngrasped\nspar\n' | awk '/ed/'
44

5-
printf 'spared no one\ngrasped\nspar\n' | awk '{r = @/ed/} 0ドル ~ r'
5+
printf 'spared no one\ngrasped\nspar\n' | awk 'BEGIN{r = @/ed/} 0ドル ~ r'
66

77
## String Anchors
88

‎example_files/buf.awk‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ f{
99
}
1010

1111
/state/{
12-
f = 0
13-
if(buf)
12+
if(f)
1413
print buf
15-
buf = ""
14+
f = 0
1615
}

‎exercises/Exercise_solutions.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ Much ado about nothing
415415
He he he
416416
417417
$ # note that there's no extra empty line at the end of the output
418-
$ awk -F'\n' -v RS= 'NF==2 && /do/{print c++ ? "\n" 0ドル : 0ドル}' sample.txt
418+
$ awk -F'\n' -v RS= 'NF==2 && /do/{print s 0ドル; s="\n"}' sample.txt
419419
Just do-it
420420
Believe it
421421
@@ -428,7 +428,7 @@ He he he
428428
```bash
429429
$ # note that there's no extra empty line at the end of the output
430430
$ awk 'BEGIN{FS="\n"; OFS=". "; RS=""} {1ドル=1ドル; $NF=$NF ".";
431-
print c++ ? "\n" 0ドル : 0ドル}' sample.txt
431+
print s 0ドル; s="\n"}' sample.txt
432432
Hello World.
433433
434434
Good day. How are you.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /