Skip to content

Instantly share code, notes, and snippets.

@fenjen
fenjen / zip-directory-exclude-subdirectories.sh
Created September 2, 2025 18:39
Zip Directory (exclude subdirectories)
# https://superuser.com/a/1922906
name='dir1' ; zip -r "$name.zip" "$name" -x "$name/.git*" -x "$name/.idea*"
@fenjen
fenjen / mktemp.sh
Last active January 17, 2025 13:38
Bash temp files and folders
# temp file in $TMPDIR or /tmp
TMPFILE="$(mktemp)"
trap '{ rm -f -- "$TMPFILE" ; }' EXIT
# temp file relative to current script
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE:-$0}")" &> /dev/null && pwd)"
TMPFILE="$(mktemp -p "$SCRIPT_DIR")"
trap '{ rm -f -- "$TMPFILE" ; }' EXIT
# temp directory in $TMPDIR or /tmp
@fenjen
fenjen / elastic.sh
Last active November 20, 2024 21:24
ElasticSearch Cheat Sheet
# Get indexes
curl 'http://localhost:9200/_cat/indices?v'
# Get index data
curl 'http://localhost:9200/index_name?pretty'
# Refresh all
for index in $(curl -s 'http://localhost:9200/_cat/indices?h=index'); do curl -sX POST "http://localhost:9200/$index/_refresh" ; echo " $index" ; done