content/wiki/sh.org

e8577d98faff1bed72ba6f2d204b8b44c6827c23
cleberg.net/content/wiki/sh.org rendered · source · history · blame · raw

49 lines · 866 bytes

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