• Generate words that contain only a certain character set

    From Ottavio Caruso@21:1/5 to All on Thu Sep 23 08:23:31 2021
    Hi,

    1) is there a Unix/Linux program that can generate words (not random characters) out of a set of characters (say: "5.tpiuongf"). If this
    doesn't exist:

    2) Is it possible to write a script that does the above out of, for
    example, /usr/share/dict/* ?

    So, I want to find all lines that contain _only_ one or more of any of "5.tpiuongf".

    Naively, I started experimenting with [e]grep but I suspect it's not the
    right way.

    --
    Ottavio Caruso

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Ottavio Caruso on Thu Sep 23 11:08:23 2021
    On 23.09.21 09:23, Ottavio Caruso wrote:
    Hi,

    1) is there a Unix/Linux program that can generate words (not random characters) out of a set of characters (say: "5.tpiuongf"). If this
    doesn't exist:

    2) Is it possible to write a script that does the above out of, for
    example, /usr/share/dict/* ?

    So, I want to find all lines that contain _only_ one or more of any of "5.tpiuongf".

    Naively, I started experimenting with [e]grep but I suspect it's not the right way.

    Well, in the past I had used to use awk for that, as in

    awk '!/[^5.tpiuongf]/'

    (i.e. working with double negation).

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Janis Papanagnou on Thu Sep 23 11:15:14 2021
    On 23.09.21 11:08, Janis Papanagnou wrote:
    On 23.09.21 09:23, Ottavio Caruso wrote:
    Hi,

    1) is there a Unix/Linux program that can generate words (not random
    characters) out of a set of characters (say: "5.tpiuongf"). If this
    doesn't exist:

    2) Is it possible to write a script that does the above out of, for
    example, /usr/share/dict/* ?

    So, I want to find all lines that contain _only_ one or more of any of
    "5.tpiuongf".

    Naively, I started experimenting with [e]grep but I suspect it's not the
    right way.

    Well, in the past I had used to use awk for that, as in

    awk '!/[^5.tpiuongf]/'

    (i.e. working with double negation).

    Using grep with the same logic is of course also possible

    grep -v '[^5.tpiuongf]'

    Janis


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ed Morton@21:1/5 to Ottavio Caruso on Thu Sep 23 08:03:20 2021
    On 9/23/2021 2:23 AM, Ottavio Caruso wrote:
    Hi,

    1) is there a Unix/Linux program that can generate words (not random characters) out of a set of characters (say: "5.tpiuongf"). If this
    doesn't exist:

    2) Is it possible to write a script that does the above out of, for
    example, /usr/share/dict/* ?

    So, I want to find all lines that contain _only_ one or more of any of "5.tpiuongf".

    Naively, I started experimenting with [e]grep but I suspect it's not the right way.


    I'm trying to understand what you mean by "word" and the difference
    between a "word" and a string of random characters to you.

    Can you define "word" in your context and give examples of words that
    contain "." and/or "5"?

    Do you just want a script that will generate random combinations of a
    specific set of characters as opposed to random combinations of all
    characters?

    If so is there any limit to how long those strings could be or how many
    times 1 character can repeat or how many of the target characters the
    string has to contain or how close duplicates of each character can be
    to each other or requirements to contain some vowels or anything else?

    Ed.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andy Walker@21:1/5 to Janis Papanagnou on Thu Sep 23 13:33:49 2021
    On 23/09/2021 10:15, Janis Papanagnou wrote:
    Using grep with the same logic is of course also possible
    grep -v '[^5.tpiuongf]'

    FWIW,

    grep '^[5.tpiuongf]*$'

    works here, and is one character shorter.

    --
    Andy Walker, Nottingham.
    Andy's music pages: www.cuboid.me.uk/andy/Music
    Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Jessel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Ottavio Caruso on Thu Sep 23 16:09:47 2021
    On 23.09.21 15:16, Ottavio Caruso wrote:
    On 23/09/2021 13:33, Andy Walker wrote:
    On 23/09/2021 10:15, Janis Papanagnou wrote:
    Using grep with the same logic is of course also possible
       grep -v '[^5.tpiuongf]'

    FWIW,

          grep '^[5.tpiuongf]*$'

    works here, and is one character shorter.


    Fantastic, that's exactly what I was looking for.

    One question: do I not have to escape the dot [.]?

    Not if it's inside the [].

    (You can test that it's not matching "any character" here.)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ottavio Caruso@21:1/5 to Andy Walker on Thu Sep 23 14:16:23 2021
    On 23/09/2021 13:33, Andy Walker wrote:
    On 23/09/2021 10:15, Janis Papanagnou wrote:
    Using grep with the same logic is of course also possible
       grep -v '[^5.tpiuongf]'

    FWIW,

         grep '^[5.tpiuongf]*$'

    works here, and is one character shorter.


    Fantastic, that's exactly what I was looking for.

    One question: do I not have to escape the dot [.]?



    --
    Ottavio Caruso

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)