Commit ab1edce1a8

ab1edce1a8557817c7f1d33ec61ce5895582c970

parent: 49ea1624d6

Unsigned

cmc <hello@cleberg.net> · 2025-03-19 05:08 UTC

add shell wiki post

Layout: unified · split

content/wiki/sh.org added +48
@@ -0,0 +1,48 @@
1#+title: sh
2
3* File Loop
4
5#+begin_sh shell
6# All files in current directory
7for file in *; do echo "${file}"; done
8
9# Files only
10for file in *; do if [ -f "$file" ]; then echo "$file"; fi; done
11
12# Directories only
13for file in *; do if [ -d "$file" ]; then echo "$file"; fi; done
14#+end_src
15
16* Exifdata
17
18#+begin_src shell
19sudo exiftool -r -all= -ext jpg -ext png .
20#+end_src
21
22* Optipng
23
24#+begin_src shell
25optipng -o7 image.png
26#+end_src
27
28* Nginx + Goaccess
29
30#+begin_src shell
31zcat /var/log/nginx/access.log.*.gz | goaccess /var/log/nginx/access.log -
32#+end_src
33
34* Distro Information
35
36#+begin_src shell
37echo /etc/*_ver* /etc/*-rel*; cat /etc/*_ver* /etc/*-rel*
38#+end_src
39
40* sed
41
42#+begin_src shell
43# Replace text within file
44sed -i '' 's/SEARCH_TEXT/REPLACEMENT_TEXT/g' file.txt
45
46# Delete empty lines
47sed '/^\s*$/d'
48#+end_src