You're viewing a comment by Rahul and its responses.

March 18, 2010, 11:12

Advised to run only with smaller sets :)
Power-set
Not a good solution but just trying to do it with pipelines alone.

cat A |xargs -n 1 ksh -c 'cat A |xargs |sed -e "s; ;,;g" -e "s;.*;{&};g" '|xargs|sed -e 's; ;\\\\\\\ ;g'|xargs -I{} ksh -c 'echo {}' > tmp
cat tmp |xargs -n 3 |cat |xargs -I{} ksh -c 'echo {} |xargs -n 1 |sort -u |xargs ' |sort -u
$cat N
1
2
3
|cat A
a
b
c
$ cat A |xargs -I{} -n 1 sh -c 'cat N |xargs -n1 echo {} '
a 1
a 2
a 3
b 1
b 2
b 3
c 1
c 2
c 3

Power set:

$ cat A |
   xargs -n 1 ksh -c 'cat A |xargs |sed -e "s; ;,;g" -e "s;.*;{&};g" ' |
       xargs |sed -e 's; ;\\\\\\\ ;g'|xargs -I{} ksh -c 'echo {}'|
           xargs -n `wc -l <A` |
               xargs -I{} sh -c 'echo {}|xargs -n 1|sort -u|xargs ' |
                   sort -u

Output:

a
a b
a b c
a c
b
b c
c

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "lcd_97": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.