I was doing research on how to generate all non-repeating permutations of a set of a numbers without using recursion in Bash and I found this answer that worked, but I want to understand why. Say you have three numbers: 1, 2, 3. The following command will generate all possible non-repeating permutations: printf "%s\n" {1,2,3}{1,2,3}{1,2,3} […]

Categories

## Can you explain this sed expression?

- Post author By Linux Questions
- Post date July 10, 2020
- No Comments on Can you explain this sed expression?

- Tags 2, 3. The following command will generate all possible non-repeating permutations: printf "%s\n" {1, 3} | sort -u | sed '/\(.\).*\1/d' 123 132 213 231 312 321 I understand what the printf with %s does when the argument is the brace expansion, 3} three times (which would print every single possible outcome). I know that sort -u will output only unique lines. I know that sed /<patt, 31, but I want to understand why. Say you have three numbers: 1, I am somewhat confused. I know how to read regex but I don't see how this pattern works within the sed command. \( = literal '(' . = any ch, I was doing research on how to generate all non-repeating permutations of a set of a numbers without using recursion in Bash and I found this, once \) = literal ')' .* = any character, when there's not really one? The parentheses are being used in the pattern to be matched literally? Everything about this execution makes sen, zero or more times \1 = reference to first captured group How does then the sed command remove non-unique values from this regex pattern? I