diff options
| author | Shulhan <ms@kilabit.info> | 2025-06-02 02:50:15 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-06-02 02:51:08 +0700 |
| commit | a06e70ea151c982daf357a16660e8c6ddb97ada5 (patch) | |
| tree | 13cfd5bcd3eec6349ca2d654d2cc1c39e4cb01c5 | |
| parent | 4d8eb7034fb990907791cd312b49ea8cd1671e6c (diff) | |
| download | kilabit.info-a06e70ea151c982daf357a16660e8c6ddb97ada5.tar.xz | |
_content/notes: add new note "sed cheat sheet"
Also add the index for directory notes.
| -rw-r--r-- | _content/notes/index.adoc | 11 | ||||
| -rw-r--r-- | _content/notes/sed_cheat_sheet/index.adoc | 28 |
2 files changed, 39 insertions, 0 deletions
diff --git a/_content/notes/index.adoc b/_content/notes/index.adoc new file mode 100644 index 0000000..5cca1a9 --- /dev/null +++ b/_content/notes/index.adoc @@ -0,0 +1,11 @@ += Notes + +link:/notes/A_guide_to_readable_and_performance_wise_code/[A guide to readable and performance wise code] + +link:/notes/A_guide_to_version_control/[A guide to version control] + +link:/notes/A_guide_to_versioning/[A guide to versioning] + +link:/notes/jenkins/[Notes on Jenkins] + +link:/notes/sed_cheat_sheet/[sed cheat sheet] diff --git a/_content/notes/sed_cheat_sheet/index.adoc b/_content/notes/sed_cheat_sheet/index.adoc new file mode 100644 index 0000000..c8658df --- /dev/null +++ b/_content/notes/sed_cheat_sheet/index.adoc @@ -0,0 +1,28 @@ += sed cheat sheet + +https://man.archlinux.org/man/sed.1[sed(1)^] +is stream editor for filtering and transforming text. +It is a powerful tool to manipulate one ore more files, for example search +and replace. + +This notes collect the cases that I use when using +https://www.gnu.org/software/sed/[GNU sed^]. + +== Replacing text + +Case 1: replace "golang.org/src/pkg" with "go.dev/src" in all asciidoc +files, + +---- +$ find . -name "*.adoc" | xargs sed -i 's#golang.org/src/pkg#go.dev/src#g' +---- + +Since the text be searched contains "/" we use the character '#' as +separator, instead of common one "/". + +Case 2: replace "http://" with "https://" but not on line that contains +"localhost" nor "127.0.0.1", + +---- +$ find . -name "*.adoc" | xargs sed -i '/\(localhost\|127.0.0.1\)/! s#http://#https://#g' +---- |
