canonify cli utility

25 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Neil Watson

ungelesen,
28.01.2014, 11:10:5128.01.14
an help-cfengine
Is there a utility to canonify strings in the shell for testing?

--
Neil H Watson
http://evolvethinking.com/evolve-thinkings-free-cfengine-library/
Hardening with Cfengine http://evolvethinking.com/products/
VIM and Cfengine https://github.com/neilhwatson/vim_cf3

Khushil Dep

ungelesen,
28.01.2014, 11:11:5228.01.14
an Neil Watson, help-cfengine
I would suggest tr Neil.

---
Khushil Dep
about.me/khushil
> --
> You received this message because you are subscribed to the Google Groups "help-cfengine" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengin...@googlegroups.com.
> To post to this group, send email to help-c...@googlegroups.com.
> Visit this group at http://groups.google.com/group/help-cfengine.
> For more options, visit https://groups.google.com/groups/opt_out.

Marco Marongiu

ungelesen,
29.01.2014, 05:42:1029.01.14
an help-c...@googlegroups.com
Il 01/28/2014 05:10 PM, Neil Watson ha scritto:
> Is there a utility to canonify strings in the shell for testing?

In a shell module of mine I use something in the lines of:

CESSID=$( echo $ESSID | tr -c "a-zA-Z0-9_" "_" | sed -e 's/_*$//' )

The sed line removes trailing underscores -- I always got one because of
a newline character in $ESSID. You may want to remove just one, or none,
or "chomp" your counterpart of ESSID beforehand.

Ciao!
-- bronto

Brian Bennett

ungelesen,
29.01.2014, 11:18:0129.01.14
an Marco Marongiu, help-c...@googlegroups.com
Use echo -n.

--
Brian

Ted Zlatanov

ungelesen,
29.01.2014, 12:42:0629.01.14
an help-c...@googlegroups.com
On Wed, 29 Jan 2014 11:42:10 +0100 Marco Marongiu <bront...@gmail.com> wrote:

MM> Il 01/28/2014 05:10 PM, Neil Watson ha scritto:
>> Is there a utility to canonify strings in the shell for testing?

MM> In a shell module of mine I use something in the lines of:

MM> CESSID=$( echo $ESSID | tr -c "a-zA-Z0-9_" "_" | sed -e 's/_*$//' )

I think Perl is a *little* bit nicer for this because of the \W
(non-word) character class:

perl -p -e's/\W/_/g'

Ted

Marco Marongiu

ungelesen,
29.01.2014, 13:00:5829.01.14
an help-c...@googlegroups.com
Il 01/29/2014 05:18 PM, Brian Bennett ha scritto:
> Use echo -n.

Argh, stupid me!!! How didn't I think about that by myself?! Thanks Brian :(

-- M
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten