content/wiki/sh.org

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

49 lines · 866 bytes

Shell Commands & Scripts

File Loop

# 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

Exifdata

sudo exiftool -r -all= -ext jpg -ext png .

Optipng

optipng -o7 image.png

Nginx + Goaccess

zcat /var/log/nginx/access.log.*.gz | goaccess /var/log/nginx/access.log -

Distro Information

echo /etc/*_ver* /etc/*-rel*; cat /etc/*_ver* /etc/*-rel*

sed

# Replace text within file
sed -i '' 's/SEARCH_TEXT/REPLACEMENT_TEXT/g' file.txt

# Delete empty lines
sed '/^\s*$/d'