diff --git a/kubetail b/kubetail index a4f2260..1290ace 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_command}" -e '$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 ${sed_command}" <( eval "${command_to_tail}" ) $line_buffered +fi \ No newline at end of file