Explode a number in bash

Multi tool use
Multi tool use












0














How would I explode out a number in bash



With this value
'12684041234'



Required result
'12684041234','1268404123','126840412','12684041','1268404','126840','12684','1268','126','12','1'










share|improve this question



























    0














    How would I explode out a number in bash



    With this value
    '12684041234'



    Required result
    '12684041234','1268404123','126840412','12684041','1268404','126840','12684','1268','126','12','1'










    share|improve this question

























      0












      0








      0


      2





      How would I explode out a number in bash



      With this value
      '12684041234'



      Required result
      '12684041234','1268404123','126840412','12684041','1268404','126840','12684','1268','126','12','1'










      share|improve this question













      How would I explode out a number in bash



      With this value
      '12684041234'



      Required result
      '12684041234','1268404123','126840412','12684041','1268404','126840','12684','1268','126','12','1'







      bash






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 27 at 13:28









      moimoi

      374




      374
























          8 Answers
          8






          active

          oldest

          votes


















          3














          I don't think that there's any built-in way to do what you want, but you can always use a loop:



          n=12684041234
          for (( i = ${#n}; i > 0; i-- )) do echo ${n:0:i}; done


          This just loops from the length of the variable $n down to 1 and prints substrings of $n.






          share|improve this answer





























            2














            The % can be used to remove prefix of a variable's value.



            Give a try to this:



            number=12684041234
            while [[ "${#number}" -gt 0 ]] ; do
            printf ",'%s'" "${number}"
            number="${number%?}"
            done | cut -b 2-


            Output



            '12684041234','1268404123','126840412','12684041','1268404','126840','12684','1268','126','12','1'





            share|improve this answer























            • You can also use while [[ -n $number ]] to loop while the variable is not empty.
              – glenn jackman
              Dec 27 at 15:22






            • 1




              @glennjackman Or just [[ $number ]] for that matter.
              – mickp
              Dec 27 at 15:28



















            1














            Using GNU awk:



            $ echo 12684041234 | awk 'BEGIN{FS=OFS=""}{for(i=NF;i>=1;i--){print;NF--}}'
            12684041234
            1268404123
            126840412
            ...





            share|improve this answer





























              1














              if n is less than or equals echo $((2**63-1))



              for((n=12684041234;n>0;n/=10));do echo $n;done





              share|improve this answer





















              • I like that loop. To match the output exactly, you could: echo "'$n'"; done | paste -sd,
                – glenn jackman
                Dec 27 at 15:25



















              1














              with dc :



              echo '12684041234' | dc -f - -e '[lap10/dsa0<Z]sZsalZx'





              share|improve this answer





























                1














                sed solution for fun:



                $ sed -n ':a;p;s/.$//;/./ba' <<< 12684041234
                12684041234
                1268404123
                126840412
                12684041
                1268404
                126840
                12684
                1268
                126
                12
                1





                share|improve this answer





























                  0














                  Using Perl and regex



                  $ export a='12684041234'

                  $ echo $a | perl -ne ' $x=$_;$i=length($x); while($i>0) { $x=~m/(.{$i})/m; print "$1n" ; $i-- } '

                  12684041234
                  1268404123
                  126840412
                  12684041
                  1268404
                  126840
                  12684
                  1268
                  126
                  12
                  1


                  Thanks to Nahuel for the below solution



                  perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234





                  share|improve this answer























                  • or perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234
                    – Nahuel Fouilleul
                    Dec 27 at 15:46










                  • @Nahuel.. yes it works..could you pls explain further.. I'll add to the answer
                    – stack0114106
                    Dec 27 at 18:00










                  • just golfed a bit for fun. explanation /../ is a regex, .+ matches at least one character as many as possible, (?{code}) allows to execute code after a partial match, to get submatches, (?!) makes the match fail and leads to backtracking, the ^ at beginning to anchor at the beginning, -E to use say to shorten.
                    – Nahuel Fouilleul
                    Dec 27 at 20:39










                  • about submatches removing anchor will give all substrings, note export is useless here, also echo + | makes a subshell which can be avoided using here-string
                    – Nahuel Fouilleul
                    Dec 27 at 20:42





















                  -1














                  I ain't thinkin' good practices, but to solver this problem. Here's how in Python the solution would be:



                  from functools import reduce

                  def f_split_word(s_word):
                  return s_word

                  def f_list_explode_word(s_word):
                  ret =
                  s_word_split = list(map(f_split_word, s_word))
                  for x in range(0, len(s_word_split)):
                  ret.append(reduce(lambda x,y: str(x) + str(y), s_word_split if x == 0 else s_word_split[:-x]))
                  return ret

                  s_word = str('12684041234')
                  print(f_list_explode_word(s_word))


                  enter image description here






                  share|improve this answer





















                    Your Answer






                    StackExchange.ifUsing("editor", function () {
                    StackExchange.using("externalEditor", function () {
                    StackExchange.using("snippets", function () {
                    StackExchange.snippets.init();
                    });
                    });
                    }, "code-snippets");

                    StackExchange.ready(function() {
                    var channelOptions = {
                    tags: "".split(" "),
                    id: "1"
                    };
                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                    StackExchange.using("externalEditor", function() {
                    // Have to fire editor after snippets, if snippets enabled
                    if (StackExchange.settings.snippets.snippetsEnabled) {
                    StackExchange.using("snippets", function() {
                    createEditor();
                    });
                    }
                    else {
                    createEditor();
                    }
                    });

                    function createEditor() {
                    StackExchange.prepareEditor({
                    heartbeatType: 'answer',
                    autoActivateHeartbeat: false,
                    convertImagesToLinks: true,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: 10,
                    bindNavPrevention: true,
                    postfix: "",
                    imageUploader: {
                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                    allowUrls: true
                    },
                    onDemand: true,
                    discardSelector: ".discard-answer"
                    ,immediatelyShowMarkdownHelp:true
                    });


                    }
                    });














                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53945896%2fexplode-a-number-in-bash%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown

























                    8 Answers
                    8






                    active

                    oldest

                    votes








                    8 Answers
                    8






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes









                    3














                    I don't think that there's any built-in way to do what you want, but you can always use a loop:



                    n=12684041234
                    for (( i = ${#n}; i > 0; i-- )) do echo ${n:0:i}; done


                    This just loops from the length of the variable $n down to 1 and prints substrings of $n.






                    share|improve this answer


























                      3














                      I don't think that there's any built-in way to do what you want, but you can always use a loop:



                      n=12684041234
                      for (( i = ${#n}; i > 0; i-- )) do echo ${n:0:i}; done


                      This just loops from the length of the variable $n down to 1 and prints substrings of $n.






                      share|improve this answer
























                        3












                        3








                        3






                        I don't think that there's any built-in way to do what you want, but you can always use a loop:



                        n=12684041234
                        for (( i = ${#n}; i > 0; i-- )) do echo ${n:0:i}; done


                        This just loops from the length of the variable $n down to 1 and prints substrings of $n.






                        share|improve this answer












                        I don't think that there's any built-in way to do what you want, but you can always use a loop:



                        n=12684041234
                        for (( i = ${#n}; i > 0; i-- )) do echo ${n:0:i}; done


                        This just loops from the length of the variable $n down to 1 and prints substrings of $n.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Dec 27 at 13:37









                        Tom Fenech

                        54.1k65290




                        54.1k65290

























                            2














                            The % can be used to remove prefix of a variable's value.



                            Give a try to this:



                            number=12684041234
                            while [[ "${#number}" -gt 0 ]] ; do
                            printf ",'%s'" "${number}"
                            number="${number%?}"
                            done | cut -b 2-


                            Output



                            '12684041234','1268404123','126840412','12684041','1268404','126840','12684','1268','126','12','1'





                            share|improve this answer























                            • You can also use while [[ -n $number ]] to loop while the variable is not empty.
                              – glenn jackman
                              Dec 27 at 15:22






                            • 1




                              @glennjackman Or just [[ $number ]] for that matter.
                              – mickp
                              Dec 27 at 15:28
















                            2














                            The % can be used to remove prefix of a variable's value.



                            Give a try to this:



                            number=12684041234
                            while [[ "${#number}" -gt 0 ]] ; do
                            printf ",'%s'" "${number}"
                            number="${number%?}"
                            done | cut -b 2-


                            Output



                            '12684041234','1268404123','126840412','12684041','1268404','126840','12684','1268','126','12','1'





                            share|improve this answer























                            • You can also use while [[ -n $number ]] to loop while the variable is not empty.
                              – glenn jackman
                              Dec 27 at 15:22






                            • 1




                              @glennjackman Or just [[ $number ]] for that matter.
                              – mickp
                              Dec 27 at 15:28














                            2












                            2








                            2






                            The % can be used to remove prefix of a variable's value.



                            Give a try to this:



                            number=12684041234
                            while [[ "${#number}" -gt 0 ]] ; do
                            printf ",'%s'" "${number}"
                            number="${number%?}"
                            done | cut -b 2-


                            Output



                            '12684041234','1268404123','126840412','12684041','1268404','126840','12684','1268','126','12','1'





                            share|improve this answer














                            The % can be used to remove prefix of a variable's value.



                            Give a try to this:



                            number=12684041234
                            while [[ "${#number}" -gt 0 ]] ; do
                            printf ",'%s'" "${number}"
                            number="${number%?}"
                            done | cut -b 2-


                            Output



                            '12684041234','1268404123','126840412','12684041','1268404','126840','12684','1268','126','12','1'






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Dec 27 at 15:21









                            glenn jackman

                            165k26142234




                            165k26142234










                            answered Dec 27 at 13:39









                            Jay jargot

                            1,9191410




                            1,9191410












                            • You can also use while [[ -n $number ]] to loop while the variable is not empty.
                              – glenn jackman
                              Dec 27 at 15:22






                            • 1




                              @glennjackman Or just [[ $number ]] for that matter.
                              – mickp
                              Dec 27 at 15:28


















                            • You can also use while [[ -n $number ]] to loop while the variable is not empty.
                              – glenn jackman
                              Dec 27 at 15:22






                            • 1




                              @glennjackman Or just [[ $number ]] for that matter.
                              – mickp
                              Dec 27 at 15:28
















                            You can also use while [[ -n $number ]] to loop while the variable is not empty.
                            – glenn jackman
                            Dec 27 at 15:22




                            You can also use while [[ -n $number ]] to loop while the variable is not empty.
                            – glenn jackman
                            Dec 27 at 15:22




                            1




                            1




                            @glennjackman Or just [[ $number ]] for that matter.
                            – mickp
                            Dec 27 at 15:28




                            @glennjackman Or just [[ $number ]] for that matter.
                            – mickp
                            Dec 27 at 15:28











                            1














                            Using GNU awk:



                            $ echo 12684041234 | awk 'BEGIN{FS=OFS=""}{for(i=NF;i>=1;i--){print;NF--}}'
                            12684041234
                            1268404123
                            126840412
                            ...





                            share|improve this answer


























                              1














                              Using GNU awk:



                              $ echo 12684041234 | awk 'BEGIN{FS=OFS=""}{for(i=NF;i>=1;i--){print;NF--}}'
                              12684041234
                              1268404123
                              126840412
                              ...





                              share|improve this answer
























                                1












                                1








                                1






                                Using GNU awk:



                                $ echo 12684041234 | awk 'BEGIN{FS=OFS=""}{for(i=NF;i>=1;i--){print;NF--}}'
                                12684041234
                                1268404123
                                126840412
                                ...





                                share|improve this answer












                                Using GNU awk:



                                $ echo 12684041234 | awk 'BEGIN{FS=OFS=""}{for(i=NF;i>=1;i--){print;NF--}}'
                                12684041234
                                1268404123
                                126840412
                                ...






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Dec 27 at 14:27









                                James Brown

                                18k31635




                                18k31635























                                    1














                                    if n is less than or equals echo $((2**63-1))



                                    for((n=12684041234;n>0;n/=10));do echo $n;done





                                    share|improve this answer





















                                    • I like that loop. To match the output exactly, you could: echo "'$n'"; done | paste -sd,
                                      – glenn jackman
                                      Dec 27 at 15:25
















                                    1














                                    if n is less than or equals echo $((2**63-1))



                                    for((n=12684041234;n>0;n/=10));do echo $n;done





                                    share|improve this answer





















                                    • I like that loop. To match the output exactly, you could: echo "'$n'"; done | paste -sd,
                                      – glenn jackman
                                      Dec 27 at 15:25














                                    1












                                    1








                                    1






                                    if n is less than or equals echo $((2**63-1))



                                    for((n=12684041234;n>0;n/=10));do echo $n;done





                                    share|improve this answer












                                    if n is less than or equals echo $((2**63-1))



                                    for((n=12684041234;n>0;n/=10));do echo $n;done






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Dec 27 at 14:36









                                    Nahuel Fouilleul

                                    14k11525




                                    14k11525












                                    • I like that loop. To match the output exactly, you could: echo "'$n'"; done | paste -sd,
                                      – glenn jackman
                                      Dec 27 at 15:25


















                                    • I like that loop. To match the output exactly, you could: echo "'$n'"; done | paste -sd,
                                      – glenn jackman
                                      Dec 27 at 15:25
















                                    I like that loop. To match the output exactly, you could: echo "'$n'"; done | paste -sd,
                                    – glenn jackman
                                    Dec 27 at 15:25




                                    I like that loop. To match the output exactly, you could: echo "'$n'"; done | paste -sd,
                                    – glenn jackman
                                    Dec 27 at 15:25











                                    1














                                    with dc :



                                    echo '12684041234' | dc -f - -e '[lap10/dsa0<Z]sZsalZx'





                                    share|improve this answer


























                                      1














                                      with dc :



                                      echo '12684041234' | dc -f - -e '[lap10/dsa0<Z]sZsalZx'





                                      share|improve this answer
























                                        1












                                        1








                                        1






                                        with dc :



                                        echo '12684041234' | dc -f - -e '[lap10/dsa0<Z]sZsalZx'





                                        share|improve this answer












                                        with dc :



                                        echo '12684041234' | dc -f - -e '[lap10/dsa0<Z]sZsalZx'






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Dec 27 at 15:27









                                        ctac_

                                        1,787138




                                        1,787138























                                            1














                                            sed solution for fun:



                                            $ sed -n ':a;p;s/.$//;/./ba' <<< 12684041234
                                            12684041234
                                            1268404123
                                            126840412
                                            12684041
                                            1268404
                                            126840
                                            12684
                                            1268
                                            126
                                            12
                                            1





                                            share|improve this answer


























                                              1














                                              sed solution for fun:



                                              $ sed -n ':a;p;s/.$//;/./ba' <<< 12684041234
                                              12684041234
                                              1268404123
                                              126840412
                                              12684041
                                              1268404
                                              126840
                                              12684
                                              1268
                                              126
                                              12
                                              1





                                              share|improve this answer
























                                                1












                                                1








                                                1






                                                sed solution for fun:



                                                $ sed -n ':a;p;s/.$//;/./ba' <<< 12684041234
                                                12684041234
                                                1268404123
                                                126840412
                                                12684041
                                                1268404
                                                126840
                                                12684
                                                1268
                                                126
                                                12
                                                1





                                                share|improve this answer












                                                sed solution for fun:



                                                $ sed -n ':a;p;s/.$//;/./ba' <<< 12684041234
                                                12684041234
                                                1268404123
                                                126840412
                                                12684041
                                                1268404
                                                126840
                                                12684
                                                1268
                                                126
                                                12
                                                1






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Dec 27 at 15:41









                                                mickp

                                                39319




                                                39319























                                                    0














                                                    Using Perl and regex



                                                    $ export a='12684041234'

                                                    $ echo $a | perl -ne ' $x=$_;$i=length($x); while($i>0) { $x=~m/(.{$i})/m; print "$1n" ; $i-- } '

                                                    12684041234
                                                    1268404123
                                                    126840412
                                                    12684041
                                                    1268404
                                                    126840
                                                    12684
                                                    1268
                                                    126
                                                    12
                                                    1


                                                    Thanks to Nahuel for the below solution



                                                    perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234





                                                    share|improve this answer























                                                    • or perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 15:46










                                                    • @Nahuel.. yes it works..could you pls explain further.. I'll add to the answer
                                                      – stack0114106
                                                      Dec 27 at 18:00










                                                    • just golfed a bit for fun. explanation /../ is a regex, .+ matches at least one character as many as possible, (?{code}) allows to execute code after a partial match, to get submatches, (?!) makes the match fail and leads to backtracking, the ^ at beginning to anchor at the beginning, -E to use say to shorten.
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 20:39










                                                    • about submatches removing anchor will give all substrings, note export is useless here, also echo + | makes a subshell which can be avoided using here-string
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 20:42


















                                                    0














                                                    Using Perl and regex



                                                    $ export a='12684041234'

                                                    $ echo $a | perl -ne ' $x=$_;$i=length($x); while($i>0) { $x=~m/(.{$i})/m; print "$1n" ; $i-- } '

                                                    12684041234
                                                    1268404123
                                                    126840412
                                                    12684041
                                                    1268404
                                                    126840
                                                    12684
                                                    1268
                                                    126
                                                    12
                                                    1


                                                    Thanks to Nahuel for the below solution



                                                    perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234





                                                    share|improve this answer























                                                    • or perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 15:46










                                                    • @Nahuel.. yes it works..could you pls explain further.. I'll add to the answer
                                                      – stack0114106
                                                      Dec 27 at 18:00










                                                    • just golfed a bit for fun. explanation /../ is a regex, .+ matches at least one character as many as possible, (?{code}) allows to execute code after a partial match, to get submatches, (?!) makes the match fail and leads to backtracking, the ^ at beginning to anchor at the beginning, -E to use say to shorten.
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 20:39










                                                    • about submatches removing anchor will give all substrings, note export is useless here, also echo + | makes a subshell which can be avoided using here-string
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 20:42
















                                                    0












                                                    0








                                                    0






                                                    Using Perl and regex



                                                    $ export a='12684041234'

                                                    $ echo $a | perl -ne ' $x=$_;$i=length($x); while($i>0) { $x=~m/(.{$i})/m; print "$1n" ; $i-- } '

                                                    12684041234
                                                    1268404123
                                                    126840412
                                                    12684041
                                                    1268404
                                                    126840
                                                    12684
                                                    1268
                                                    126
                                                    12
                                                    1


                                                    Thanks to Nahuel for the below solution



                                                    perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234





                                                    share|improve this answer














                                                    Using Perl and regex



                                                    $ export a='12684041234'

                                                    $ echo $a | perl -ne ' $x=$_;$i=length($x); while($i>0) { $x=~m/(.{$i})/m; print "$1n" ; $i-- } '

                                                    12684041234
                                                    1268404123
                                                    126840412
                                                    12684041
                                                    1268404
                                                    126840
                                                    12684
                                                    1268
                                                    126
                                                    12
                                                    1


                                                    Thanks to Nahuel for the below solution



                                                    perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234






                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited 2 days ago

























                                                    answered Dec 27 at 14:09









                                                    stack0114106

                                                    2,0051416




                                                    2,0051416












                                                    • or perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 15:46










                                                    • @Nahuel.. yes it works..could you pls explain further.. I'll add to the answer
                                                      – stack0114106
                                                      Dec 27 at 18:00










                                                    • just golfed a bit for fun. explanation /../ is a regex, .+ matches at least one character as many as possible, (?{code}) allows to execute code after a partial match, to get submatches, (?!) makes the match fail and leads to backtracking, the ^ at beginning to anchor at the beginning, -E to use say to shorten.
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 20:39










                                                    • about submatches removing anchor will give all substrings, note export is useless here, also echo + | makes a subshell which can be avoided using here-string
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 20:42




















                                                    • or perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 15:46










                                                    • @Nahuel.. yes it works..could you pls explain further.. I'll add to the answer
                                                      – stack0114106
                                                      Dec 27 at 18:00










                                                    • just golfed a bit for fun. explanation /../ is a regex, .+ matches at least one character as many as possible, (?{code}) allows to execute code after a partial match, to get submatches, (?!) makes the match fail and leads to backtracking, the ^ at beginning to anchor at the beginning, -E to use say to shorten.
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 20:39










                                                    • about submatches removing anchor will give all substrings, note export is useless here, also echo + | makes a subshell which can be avoided using here-string
                                                      – Nahuel Fouilleul
                                                      Dec 27 at 20:42


















                                                    or perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234
                                                    – Nahuel Fouilleul
                                                    Dec 27 at 15:46




                                                    or perl -nE '/^.+(?{say$&})(?!)/' <<<12684041234
                                                    – Nahuel Fouilleul
                                                    Dec 27 at 15:46












                                                    @Nahuel.. yes it works..could you pls explain further.. I'll add to the answer
                                                    – stack0114106
                                                    Dec 27 at 18:00




                                                    @Nahuel.. yes it works..could you pls explain further.. I'll add to the answer
                                                    – stack0114106
                                                    Dec 27 at 18:00












                                                    just golfed a bit for fun. explanation /../ is a regex, .+ matches at least one character as many as possible, (?{code}) allows to execute code after a partial match, to get submatches, (?!) makes the match fail and leads to backtracking, the ^ at beginning to anchor at the beginning, -E to use say to shorten.
                                                    – Nahuel Fouilleul
                                                    Dec 27 at 20:39




                                                    just golfed a bit for fun. explanation /../ is a regex, .+ matches at least one character as many as possible, (?{code}) allows to execute code after a partial match, to get submatches, (?!) makes the match fail and leads to backtracking, the ^ at beginning to anchor at the beginning, -E to use say to shorten.
                                                    – Nahuel Fouilleul
                                                    Dec 27 at 20:39












                                                    about submatches removing anchor will give all substrings, note export is useless here, also echo + | makes a subshell which can be avoided using here-string
                                                    – Nahuel Fouilleul
                                                    Dec 27 at 20:42






                                                    about submatches removing anchor will give all substrings, note export is useless here, also echo + | makes a subshell which can be avoided using here-string
                                                    – Nahuel Fouilleul
                                                    Dec 27 at 20:42













                                                    -1














                                                    I ain't thinkin' good practices, but to solver this problem. Here's how in Python the solution would be:



                                                    from functools import reduce

                                                    def f_split_word(s_word):
                                                    return s_word

                                                    def f_list_explode_word(s_word):
                                                    ret =
                                                    s_word_split = list(map(f_split_word, s_word))
                                                    for x in range(0, len(s_word_split)):
                                                    ret.append(reduce(lambda x,y: str(x) + str(y), s_word_split if x == 0 else s_word_split[:-x]))
                                                    return ret

                                                    s_word = str('12684041234')
                                                    print(f_list_explode_word(s_word))


                                                    enter image description here






                                                    share|improve this answer


























                                                      -1














                                                      I ain't thinkin' good practices, but to solver this problem. Here's how in Python the solution would be:



                                                      from functools import reduce

                                                      def f_split_word(s_word):
                                                      return s_word

                                                      def f_list_explode_word(s_word):
                                                      ret =
                                                      s_word_split = list(map(f_split_word, s_word))
                                                      for x in range(0, len(s_word_split)):
                                                      ret.append(reduce(lambda x,y: str(x) + str(y), s_word_split if x == 0 else s_word_split[:-x]))
                                                      return ret

                                                      s_word = str('12684041234')
                                                      print(f_list_explode_word(s_word))


                                                      enter image description here






                                                      share|improve this answer
























                                                        -1












                                                        -1








                                                        -1






                                                        I ain't thinkin' good practices, but to solver this problem. Here's how in Python the solution would be:



                                                        from functools import reduce

                                                        def f_split_word(s_word):
                                                        return s_word

                                                        def f_list_explode_word(s_word):
                                                        ret =
                                                        s_word_split = list(map(f_split_word, s_word))
                                                        for x in range(0, len(s_word_split)):
                                                        ret.append(reduce(lambda x,y: str(x) + str(y), s_word_split if x == 0 else s_word_split[:-x]))
                                                        return ret

                                                        s_word = str('12684041234')
                                                        print(f_list_explode_word(s_word))


                                                        enter image description here






                                                        share|improve this answer












                                                        I ain't thinkin' good practices, but to solver this problem. Here's how in Python the solution would be:



                                                        from functools import reduce

                                                        def f_split_word(s_word):
                                                        return s_word

                                                        def f_list_explode_word(s_word):
                                                        ret =
                                                        s_word_split = list(map(f_split_word, s_word))
                                                        for x in range(0, len(s_word_split)):
                                                        ret.append(reduce(lambda x,y: str(x) + str(y), s_word_split if x == 0 else s_word_split[:-x]))
                                                        return ret

                                                        s_word = str('12684041234')
                                                        print(f_list_explode_word(s_word))


                                                        enter image description here







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Dec 27 at 14:44









                                                        Carlos Mesquita Aguiar

                                                        92




                                                        92






























                                                            draft saved

                                                            draft discarded




















































                                                            Thanks for contributing an answer to Stack Overflow!


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid



                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                            To learn more, see our tips on writing great answers.





                                                            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                            Please pay close attention to the following guidance:


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid



                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                            To learn more, see our tips on writing great answers.




                                                            draft saved


                                                            draft discarded














                                                            StackExchange.ready(
                                                            function () {
                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53945896%2fexplode-a-number-in-bash%23new-answer', 'question_page');
                                                            }
                                                            );

                                                            Post as a guest















                                                            Required, but never shown





















































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown

































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown







                                                            G0 3QmsjPRjP9PtZp uTr qYS Sys
                                                            Y,LAB8jjw Oec HPJ2Uz0zQDvdtvusFFIQU9wLSNVSM6uyiWh6vlqimJb1VGIEQ25bfcdKVpszMu0 s9GVb ey

                                                            Popular posts from this blog

                                                            Monofisismo

                                                            Angular Downloading a file using contenturl with Basic Authentication

                                                            Olmecas