variable substitution, leading tab retained, overwrite file, echo to stdout
tee /path/to/file <<EOF
${variable}
EOF
no variable substitution, leading tab retained, overwrite file, echo to stdout
#!/usr/bin/env bash | |
#Templating | |
#More examples: https://unix.stackexchange.com/questions/73969/how-can-i-use-sed-or-awk-to-replace-placeholders-in-a-template-file-with-variabl | |
sed -e "s/\${i}/1/" -e "s/\${word}/dog/" template.txt > result.txt |
#!/bin/bash | |
# Stolen from: https://github.com/joemiller/docker-tail/blob/master/Makefile ;) | |
# `tail -f` the logs of one or more docker containers, with each log line prefixed | |
# with the container name and a color. | |
# | |
VERSION="0.1.0" | |
# set of colors for output. We rotate through them and re-use. | |
COLORS=("\x1b[31m" "\x1b[32m" "\x1b[33m" "\x1b[34m" "\x1b[35m") |
variable substitution, leading tab retained, overwrite file, echo to stdout
tee /path/to/file <<EOF
${variable}
EOF
no variable substitution, leading tab retained, overwrite file, echo to stdout
#!/usr/bin/env bash | |
# Export CA | |
kubectl config view --minify --raw --output 'jsonpath={..cluster.certificate-authority-data}' | base64 -D > ca.crt | |
# Export Client Cert | |
kubectl config view --minify --raw --output 'jsonpath={..user.client-certificate-data}' | base64 -D > client.crt | |
# Export Client Key | |
kubectl config view --minify --raw --output 'jsonpath={..user.client-key-data}' | base64 -D >client.key | |
# Usage: | |
curl -k --cert client.crt --key client.key --cacert ca.crt https://[K8S_HOST]:6443/api/v1/pod |
version: '3' | |
services: | |
logs: | |
image: gerchardon/docker-logio | |
links: | |
- logio:logio | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
command: -h logio -n docker | |
privileged: true |
cat /proc/sys/kernel/random/entropy_avail | |
# around 5 | |
apt install -y haveged | |
systemctl status haveged.service | |
cat /proc/sys/kernel/random/entropy_avail | |
# 2400 or more |
alias dns="scutil --dns | grep 'nameserver\[[0-9]*\]'" | |
alias ffile='function __ffile(){if [ -z $2 ]; then _loc=".";else _loc="${2}";fi; if [ -z $1 ]; then echo "use: ffile [filename] [path]";else find "${_loc}" -type f -iname "*$1*" 2>/dev/null;unset -f __ffile;fi }; __ffile' | |
alias create-ssh-key='function _create(){SUFFIX=$(date +%Y%m%d_%H%M%S);ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519_${SUFFIX}_wheelq -C "id_ed25519_${SUFFIX}_wheelq"; unset -f _create;echo -e "Key: ${HOME}/.ssh/id_ed25519_${SUFFIX}_wheelq\n\n$(cat ${HOME}/.ssh/id_ed25519_${SUFFIX}_wheelq.pub)"};_create' |
#echo "alias go=' function __go(){ docker run --rm -v \"\${PWD}:/usr/src/myapp\" -w /usr/src/myapp -it golang:latest go \$@;unset -f __go;}; __go'"|tee -a ~/.bash_profile >> ~/.bashrc | |
echo -e "#\!/usr/bin/env bash\nfunction __go(){ docker run --rm -v \"\${PWD}:/usr/src/myapp\" -w /usr/src/myapp -it golang:latest go \$@;unset -f __go;}; __go \$@" > /usr/local/bin/go && chmod 755 /usr/local/bin/go |
#echo "alias terraform=' function __terraform(){ docker run --rm -v \"\${PWD}:/src\" -w /src -v ~/.terraform.d:/root/.terraform.d -it hashicorp/terraform:light \$@;unset -f __terraform;}; __terraform'"|tee -a ~/.bash_profile >> ~/.bashrc | |
echo -e "#\!/usr/bin/env bash\nfunction __terraform(){ docker run --rm -v \"\${PWD}:/src\" -w /src -v ~/.terraform.d:/root/.terraform.d -it hashicorp/terraform:light \$@;unset -f __terraform;}; __terraform \$@" >/usr/local/bin/terraform && chmod 755 /usr/local/bin/terraform |