Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new feature, sed, Manipulate lines using sed #79

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions kubetail
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dryrun=false
cluster=""
namespace_arg=""

usage="${PROGNAME} <search term> [-h] [-c] [-n] [-t] [-l] [-d] [-p] [-s] [-b] [-k] [-v] [-r] -- tail multiple Kubernetes pod logs at the same time
usage="${PROGNAME} <search term> [-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
Expand All @@ -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
Expand Down Expand Up @@ -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
;;
Expand Down Expand Up @@ -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