Commit ab1edce1a8
Unsigned
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 | |
| 7 | for file in *; do echo "${file}"; done | |
| 8 | ||
| 9 | # Files only | |
| 10 | for file in *; do if [ -f "$file" ]; then echo "$file"; fi; done | |
| 11 | ||
| 12 | # Directories only | |
| 13 | for file in *; do if [ -d "$file" ]; then echo "$file"; fi; done | |
| 14 | #+end_src | |
| 15 | ||
| 16 | * Exifdata | |
| 17 | ||
| 18 | #+begin_src shell | |
| 19 | sudo exiftool -r -all= -ext jpg -ext png . | |
| 20 | #+end_src | |
| 21 | ||
| 22 | * Optipng | |
| 23 | ||
| 24 | #+begin_src shell | |
| 25 | optipng -o7 image.png | |
| 26 | #+end_src | |
| 27 | ||
| 28 | * Nginx + Goaccess | |
| 29 | ||
| 30 | #+begin_src shell | |
| 31 | zcat /var/log/nginx/access.log.*.gz | goaccess /var/log/nginx/access.log - | |
| 32 | #+end_src | |
| 33 | ||
| 34 | * Distro Information | |
| 35 | ||
| 36 | #+begin_src shell | |
| 37 | echo /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 | |
| 44 | sed -i '' 's/SEARCH_TEXT/REPLACEMENT_TEXT/g' file.txt | |
| 45 | ||
| 46 | # Delete empty lines | |
| 47 | sed '/^\s*$/d' | |
| 48 | #+end_src | |