Skip to content

Instantly share code, notes, and snippets.

@agile6v
agile6v / gist:6cc97177ede8a32ca4ed36f668659451
Created November 3, 2018 10:24
Replace all newline with a comma except the last line
sed -n '1h;1!H;${g;s/\n/,/g;p;}'
For example:
ip a | grep inet | grep -v inet6 |sed 's/^[ \t]*//g' | cut -d ' ' -f2 | sed -n '1h;1!H;${g;s/\n/,/g;p;}'
@agile6v
agile6v / dockerpsns.sh
Created April 14, 2018 10:07 — forked from brendangregg/dockerpsns.sh
docker ps --namespaces
#!/bin/bash
#
# dockerpsns - proof of concept for a "docker ps --namespaces".
#
# USAGE: ./dockerpsns.sh
#
# This lists containers, their init PIDs, and namespace IDs. If container
# namespaces equal the host namespace, they are colored red (this can be
# disabled by setting color=0 below).
#
@agile6v
agile6v / gist:a3689b59327d369edb42e27a472ef129
Created April 12, 2018 13:59
How to copy docker images from one host to another without via repository?
step1: docker save -o <save image to path> <image name>
step2: scp file to dest host
step3: docker load -i <path to image tar file>
@agile6v
agile6v / gist:b11a8ed8b3a2d7f22852c7b7bf7e2515
Last active January 6, 2018 15:49
Check the specified process resource usage
top -d 1 -p `pidof PROCESS_NAME | sed 's/ /,/g'`