Generate a random string using shell command:
head /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | head -c128
Generate a random string using shell command:
head /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | head -c128
| ``` | |
| #!/bin/bash | |
| # List all S3 buckets | |
| buckets=$(aws s3 ls | awk '{print $3}') | |
| # Print the list of buckets and their region | |
| echo "List of S3 buckets and their regions:" | |
| for bucket in $buckets | |
| do |
| ``` | |
| #!/bin/bash | |
| # Define the name of the CSV file | |
| file="bucket_list.csv" | |
| # Read the CSV file and calculate the size of each bucket | |
| while IFS=',' read -r name region | |
| do | |
| echo "Calculating size of bucket: $name in region $region" |
| set number | |
| set incsearch | |
| set mouse=a | |
| set tabstop=2 | |
| set shiftwidth=2 | |
| set expandtab | |
| set autoindent | |
| set smartindent | |
| set nocompatible | |
| syntax on |
| # decrypt gpg and untar to the basename | |
| tgx() { | |
| if [[ $# -ne 1 ]]; then | |
| echo "Usage: tgx <file.tar.gz.gpg>" | |
| return 1 | |
| fi | |
| local input_file="$1" | |
| local base_name="${input_file%.tar.gz.gpg}" | |
| local output_dir="${base_name}" |
A simple Bash/Zsh function to SSH into a remote machine and automatically cd into a directory that mirrors your current local path, relative to your home directory.
Save the function: Add this entire block to your shell's configuration file (e.g., ~/.bashrc, ~/.zshrc, or ~/.bash_profile).
Source your config: After saving, apply the changes by running source ~/.bashrc (or your respective file), or simply open a new terminal session.