From 08db0cd33f07c33f6b753025d6d613bff10ca5fc Mon Sep 17 00:00:00 2001 From: Jihui Choi Date: Fri, 1 Feb 2019 12:20:52 +0900 Subject: [PATCH 1/3] add new feature, sed, Manipulate lines using sed --- kubetail | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kubetail b/kubetail index a4f2260..bd3143d 100755 --- a/kubetail +++ b/kubetail @@ -38,7 +38,7 @@ dryrun=false cluster="" namespace_arg="" -usage="${PROGNAME} [-h] [-c] [-n] [-t] [-l] [-d] [-p] [-s] [-b] [-k] [-v] [-r] -- tail multiple Kubernetes pod logs at the same time +usage="${PROGNAME} [-h] [-c] [-n] [-t] [-l] [-d] [-p] [-s] [-b] [-k] [-v] [-r] [-sed] -- tail multiple Kubernetes pod logs at the same time where: -h, --help Show this help text @@ -65,6 +65,7 @@ where: --tail Lines of recent log file to display. Defaults to ${default_tail}, showing all log lines. -v, --version Prints the kubetail version -r, --cluster The name of the kubeconfig cluster to use. + -sed, --sed Manipulate lines using sed. ex) -sed 's/foo/bar/g' examples: ${PROGNAME} my-pod-v1 @@ -174,6 +175,13 @@ if [ "$#" -ne 0 ]; then tail="$2" fi ;; + -sed|--sed) + if [ -z "$2" ]; then + sed_command="" + else + sed_command="sed '$2'" + fi + ;; --) break ;; @@ -329,4 +337,9 @@ if [[ ${follow} == false ]]; then tail_follow_command="" fi -tail ${tail_follow_command} -n +1 <( eval "${command_to_tail}" ) $line_buffered + +if [ "${sed_command}" = "" ]; then + tail ${tail_follow_command} -n +1 <( eval "${command_to_tail}" ) $line_buffered +else + tail ${tail_follow_command} -n +1 | eval "${sed_command}" <( eval "${command_to_tail}" ) $line_buffered +fi \ No newline at end of file From 97b52bfc810c6a86e9ed1659f00d4d443452e28f Mon Sep 17 00:00:00 2001 From: Jihui Choi Date: Fri, 1 Feb 2019 14:16:46 +0900 Subject: [PATCH 2/3] change multiple sed commands available --- kubetail | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kubetail b/kubetail index bd3143d..15aadbe 100755 --- a/kubetail +++ b/kubetail @@ -179,7 +179,7 @@ if [ "$#" -ne 0 ]; then if [ -z "$2" ]; then sed_command="" else - sed_command="sed '$2'" + sed_command=${sed_command}" -e '$2'" fi ;; --) @@ -341,5 +341,5 @@ fi if [ "${sed_command}" = "" ]; then tail ${tail_follow_command} -n +1 <( eval "${command_to_tail}" ) $line_buffered else - tail ${tail_follow_command} -n +1 | eval "${sed_command}" <( eval "${command_to_tail}" ) $line_buffered + tail ${tail_follow_command} -n +1 | eval "sed ${sed_command}" <( eval "${command_to_tail}" ) $line_buffered fi \ No newline at end of file From f1ca5fea03e93a46fd79c4a003633f7f6fa2d051 Mon Sep 17 00:00:00 2001 From: Jihui Choi Date: Thu, 7 Feb 2019 02:45:11 +0900 Subject: [PATCH 3/3] misc change tap to space for consistency --- kubetail | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kubetail b/kubetail index 15aadbe..1290ace 100755 --- a/kubetail +++ b/kubetail @@ -65,7 +65,7 @@ where: --tail Lines of recent log file to display. Defaults to ${default_tail}, showing all log lines. -v, --version Prints the kubetail version -r, --cluster The name of the kubeconfig cluster to use. - -sed, --sed Manipulate lines using sed. ex) -sed 's/foo/bar/g' + -sed, --sed Manipulate lines using sed. ex) -sed 's/foo/bar/g' examples: ${PROGNAME} my-pod-v1 @@ -175,11 +175,11 @@ if [ "$#" -ne 0 ]; then tail="$2" fi ;; - -sed|--sed) - if [ -z "$2" ]; then - sed_command="" - else - sed_command=${sed_command}" -e '$2'" + -sed|--sed) + if [ -z "$2" ]; then + sed_command="" + else + sed_command=${sed_command}" -e '$2'" fi ;; --) @@ -339,7 +339,7 @@ then fi if [ "${sed_command}" = "" ]; then - tail ${tail_follow_command} -n +1 <( eval "${command_to_tail}" ) $line_buffered + tail ${tail_follow_command} -n +1 <( eval "${command_to_tail}" ) $line_buffered else - tail ${tail_follow_command} -n +1 | eval "sed ${sed_command}" <( eval "${command_to_tail}" ) $line_buffered + tail ${tail_follow_command} -n +1 | eval "sed ${sed_command}" <( eval "${command_to_tail}" ) $line_buffered fi \ No newline at end of file