Skip to content

Commit

Permalink
updates for version 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
learnbyexample committed Jun 28, 2023
1 parent e5e0745 commit babbde1
Show file tree
Hide file tree
Showing 35 changed files with 3,062 additions and 1,646 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Sundeep Agarwal
Copyright (c) 2023 Sundeep Agarwal

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
62 changes: 30 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
# GNU SED
# CLI text processing with GNU sed

Example based guide to mastering GNU sed.

<p align="center">
<img src="./images/sed.png" width="320px" height="400px" />
</p>
<p align="center"><img src="./images/sed_ls.png" alt="CLI text processing with GNU sed ebook cover image" /></p>

The book also includes exercises to test your understanding, which is presented together as a single file in this repo — [Exercises.md](./exercises/Exercises.md)
The book also includes exercises to test your understanding, which are presented together as a single file in this repo — [Exercises.md](./exercises/Exercises.md)

For solutions to the exercises, see [Exercise_solutions.md](./exercises/Exercise_solutions.md).

You can also use [this interactive TUI app](https://github.com/learnbyexample/TUI-apps/blob/main/SedExercises) to practice some of the exercises from the book.

See [Version_changes.md](./Version_changes.md) to keep track of changes made to the book.

<br>

# E-book

You can purchase the pdf/epub versions of the book using these links:

* https://learnbyexample.gumroad.com/l/gnu_sed
* https://leanpub.com/gnu_sed

You can also get the book as part of these bundles:

* **Magical one-liners** bundle from https://learnbyexample.gumroad.com/l/oneliners or https://leanpub.com/b/oneliners
* **Awesome Regex** bundle from https://learnbyexample.gumroad.com/l/regex or https://leanpub.com/b/regex
* **All books bundle** bundle from https://learnbyexample.gumroad.com/l/all-books
* Includes all my programming books

See https://learnbyexample.github.io/books/ for list of other books
* You can purchase the pdf/epub versions of the book using these links:
* https://learnbyexample.gumroad.com/l/gnu_sed
* https://leanpub.com/gnu_sed
* You can also get the book as part of these bundles:
* **All books bundle** bundle from https://learnbyexample.gumroad.com/l/all-books
* Includes all my programming books
* **Magical one-liners** bundle from https://learnbyexample.gumroad.com/l/oneliners or https://leanpub.com/b/oneliners
* **Awesome Regex** bundle from https://learnbyexample.gumroad.com/l/regex or https://leanpub.com/b/regex
* See https://learnbyexample.github.io/books/ for a list of other books

For a preview of the book, see [sample chapters](https://github.com/learnbyexample/learn_gnused/blob/master/sample_chapters/gnu_sed_sample.pdf)
For a preview of the book, see [sample chapters](./sample_chapters/gnu_sed_sample.pdf).

The book can also be [viewed as a single markdown file in this repo](./gnu_sed.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.
The book can also be [viewed as a single markdown file in this repo](./gnu_sed.md). See my blogpost on [generating pdfs from markdown using pandoc](https://learnbyexample.github.io/tutorial/ebook-generation/customizing-pandoc/) if you are interested in the ebook creation process.

For web version of the book, visit https://learnbyexample.github.io/learn_gnused/
For the web version of the book, visit https://learnbyexample.github.io/learn_gnused/

<br>

Expand All @@ -46,15 +42,17 @@ For web version of the book, visit https://learnbyexample.github.io/learn_gnused
<br>

# Feedback
# Feedback and Contributing

[Open an issue](https://github.com/learnbyexample/learn_gnused/issues) if you spot any typo/errors.
⚠️ ⚠️ Please DO NOT submit pull requests. Main reason being any modification requires changes in multiple places.

:warning: :warning: Please DO NOT submit pull requests. Main reason being any modification requires changes in multiple places.
I would highly appreciate if you'd let me know how you felt about this book. It could be anything from a simple thank you, pointing out a typo, mistakes in code snippets, which aspects of the book worked for you (or didn't!) and so on. Reader feedback is essential and especially so for self-published authors.

I'd also highly appreciate your feedback about the book.
You can reach me via:

Twitter: https://twitter.com/learn_byexample
* Issue Manager: [https://github.com/learnbyexample/learn_gnused/issues](https://github.com/learnbyexample/learn_gnused/issues)
* E-mail: `echo 'bGVhcm5ieWV4YW1wbGUubmV0QGdtYWlsLmNvbQo=' | base64 --decode`
* Twitter: [https://twitter.com/learn_byexample](https://twitter.com/learn_byexample)

<br>

Expand All @@ -80,11 +78,11 @@ Twitter: https://twitter.com/learn_byexample
# Acknowledgements

* [GNU sed documentation](https://www.gnu.org/software/sed/manual/sed.html) — manual and examples
* [stackoverflow](https://stackoverflow.com/) and [unix.stackexchange](https://unix.stackexchange.com/) — for getting answers to pertinent questions on `bash`, `sed` and other commands
* [stackoverflow](https://stackoverflow.com/) and [unix.stackexchange](https://unix.stackexchange.com/) — for getting answers to pertinent questions on `sed` and related commands
* [tex.stackexchange](https://tex.stackexchange.com/) — for help on [pandoc](https://github.com/jgm/pandoc/) and `tex` related questions
* [LibreOffice Draw](https://www.libreoffice.org/discover/draw/) — cover image
* [pngquant](https://pngquant.org/) and [svgcleaner](https://github.com/RazrFalcon/svgcleaner) for optimizing images
* [softwareengineering.stackexchange](https://softwareengineering.stackexchange.com/questions/39/whats-your-favourite-quote-about-programming) and [skolakoda](https://skolakoda.org/programming-quotes) for programming quotes
* [/r/commandline/](https://old.reddit.com/r/commandline), [/r/linux4noobs/](https://old.reddit.com/r/linux4noobs/), [/r/linuxquestions/](https://old.reddit.com/r/linuxquestions/) and [/r/linux/](https://old.reddit.com/r/linux/) — helpful forums
* [canva](https://www.canva.com/) — cover image
* [oxipng](https://github.com/shssoichiro/oxipng), [pngquant](https://pngquant.org/) and [svgcleaner](https://github.com/RazrFalcon/svgcleaner) — optimizing images
* [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
* [arifmahmudrana](https://github.com/arifmahmudrana) for spotting an ambiguous explanation
* [mdBook](https://github.com/rust-lang/mdBook) — for web version of the book
Expand All @@ -97,7 +95,7 @@ Special thanks to all my friends and online acquaintances for their help, suppor

# License

The book is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/)
The book is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/).

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

14 changes: 14 additions & 0 deletions Version_changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<br>

### 2.0

* Command version updated to **GNU sed 4.9**
* Many more exercises added, and you can practice some of them using this [interactive TUI app](https://github.com/learnbyexample/TUI-apps/blob/main/SedExercises)
* Long sections split into smaller ones
* In general, many of the examples, exercises, solutions, descriptions and external links were updated/corrected
* Updated Acknowledgements section
* Code snippets related to info/warning sections will now appear as a single block
* Book title changed to **CLI text processing with GNU sed**
* New cover image
* Images centered for EPUB format

<br>

### 1.5

* Clarified use of `/dev/stdin` with the `r` command
Expand Down
24 changes: 11 additions & 13 deletions code_snippets/Adding_content_from_file.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## r for entire file
## Append entire file using r

cat ip.txt

cat fav_colors.txt
cat fav_color.txt

sed '/red/r ip.txt' fav_colors.txt
sed '/red/r ip.txt' fav_color.txt

text='good\tone\nfood\tpun'

Expand All @@ -14,23 +14,21 @@ seq 2 | sed '2r /dev/stdin' ip.txt

printf '123' | sed '1r /dev/stdin' ip.txt

sed '0r ip.txt' greeting.txt

items=' * blue\n * green\n'

printf '%b' "$items" | sed -e '2 {r /dev/stdin' -e 'd}' ip.txt

sed -e '/^red/r ip.txt' -e '/yellow/,//d' fav_colors.txt

## Using e and cat command
sed -e '/yellow/r ip.txt' -e '//,/^red/d' fav_color.txt

sed '/red/e cat ip.txt' fav_colors.txt

text='good\tone\nfood\tpun'
## Insert file using e and cat

echo "$text" | sed '1e cat /dev/stdin' ip.txt
sed '/red/e cat ip.txt' fav_color.txt

## R for line by line
## Append line by line using R

sed '/red/R ip.txt' fav_colors.txt
sed '/red/R ip.txt' fav_color.txt

seq 4 | sed 'R /dev/stdin' fav_colors.txt
seq 4 | sed 'R /dev/stdin' fav_color.txt

Loading

0 comments on commit babbde1

Please sign in to comment.