From 6a85aeb444b50a25920e1dc922fd417b9dff239c Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Fri, 20 Mar 2020 21:25:24 +0100 Subject: [PATCH] Document trim option for shell commands. Fix #201 --- docs/matches.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/matches.md b/docs/matches.md index 98422ef..5d0852a 100644 --- a/docs/matches.md +++ b/docs/matches.md @@ -397,6 +397,24 @@ This extension also supports bash **pipes** as your shell, such as: ``` {% endraw %} +#### Trimming the output + +When working with commands, it's very common to have outputs that also spawn a newline at the end. If you want to remove any +excess spaces/newlines, you can use the `trim` option: + +{% raw %} +```yml +- trigger: ":localip" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: "ip a | grep 'inet 192' | awk '{ print $2 }'" + trim: true +``` +{% endraw %} + ### Date Extension The **Date Extension** can be used to include *date* and *time* information in a match.