cmc/cleberg.net

My personal web garden & blog.

clone: git clone https://gitbay.org/cmc/cleberg.net.git

ab1edce1a8557817c7f1d33ec61ce5895582c970

unsigned

author: Christian Cleberg <hello@cleberg.net> · 2025-03-19T05:08:06Z

add shell wiki post
 content/wiki/sh.org | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/content/wiki/sh.org b/content/wiki/sh.org
new file mode 100644
index 0000000..7399898
--- /dev/null
+++ b/content/wiki/sh.org
@@ -0,0 +1,48 @@
+#+title: sh
+
+* File Loop
+
+#+begin_sh shell
+# All files in current directory
+for file in *; do echo "${file}"; done
+
+# Files only
+for file in *; do if [ -f "$file" ]; then echo "$file"; fi; done
+
+# Directories only
+for file in *; do if [ -d "$file" ]; then echo "$file"; fi; done
+#+end_src
+
+* Exifdata
+
+#+begin_src shell
+sudo exiftool -r -all= -ext jpg -ext png .
+#+end_src
+
+* Optipng
+
+#+begin_src shell
+optipng -o7 image.png
+#+end_src
+
+* Nginx + Goaccess
+
+#+begin_src shell
+zcat /var/log/nginx/access.log.*.gz | goaccess /var/log/nginx/access.log -
+#+end_src
+
+* Distro Information
+
+#+begin_src shell
+echo /etc/*_ver* /etc/*-rel*; cat /etc/*_ver* /etc/*-rel*
+#+end_src
+
+* sed
+
+#+begin_src shell
+# Replace text within file
+sed -i '' 's/SEARCH_TEXT/REPLACEMENT_TEXT/g' file.txt
+
+# Delete empty lines
+sed '/^\s*$/d'
+#+end_src