multiply digits within a number with each other
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
I have list of numbers and I want to multiply the digits within each number with each other.
for example number 1234 is 1X2X3X4=24
I have this list for example
7675342567
098765342567
1234567890
0987654
234567
8765678
98
0999
09876543
345678
876543
87654
the results must be
7408800
0
0
0
5040
564480
72
0
0
20160
20160
6720
how can i do it please help i don't know bash at all . i searched a lot on the internet and i could not figure out how to do it please help
bash
New contributor
 |Â
show 1 more comment
up vote
4
down vote
favorite
I have list of numbers and I want to multiply the digits within each number with each other.
for example number 1234 is 1X2X3X4=24
I have this list for example
7675342567
098765342567
1234567890
0987654
234567
8765678
98
0999
09876543
345678
876543
87654
the results must be
7408800
0
0
0
5040
564480
72
0
0
20160
20160
6720
how can i do it please help i don't know bash at all . i searched a lot on the internet and i could not figure out how to do it please help
bash
New contributor
6
why downvote please help
â Sydney
49 mins ago
2
please see my answer below and upvote from me ;-)
â Goro
48 mins ago
Sorry but this is not a scripting service. If you do not know any shell scripting, you'd start learning.
â andcoz
48 mins ago
6
@andcoz i don't like programming and it is not my hobby, I have problem and I need help what is wrong with that?
â Sydney
46 mins ago
1
Sydney: The problem is that this site teaches people programming. If you don't care about the "how", pay someone to solve the problem for you.
â choroba
36 mins ago
 |Â
show 1 more comment
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I have list of numbers and I want to multiply the digits within each number with each other.
for example number 1234 is 1X2X3X4=24
I have this list for example
7675342567
098765342567
1234567890
0987654
234567
8765678
98
0999
09876543
345678
876543
87654
the results must be
7408800
0
0
0
5040
564480
72
0
0
20160
20160
6720
how can i do it please help i don't know bash at all . i searched a lot on the internet and i could not figure out how to do it please help
bash
New contributor
I have list of numbers and I want to multiply the digits within each number with each other.
for example number 1234 is 1X2X3X4=24
I have this list for example
7675342567
098765342567
1234567890
0987654
234567
8765678
98
0999
09876543
345678
876543
87654
the results must be
7408800
0
0
0
5040
564480
72
0
0
20160
20160
6720
how can i do it please help i don't know bash at all . i searched a lot on the internet and i could not figure out how to do it please help
bash
bash
New contributor
New contributor
edited 51 mins ago
Goro
7,54253270
7,54253270
New contributor
asked 51 mins ago
Sydney
312
312
New contributor
New contributor
6
why downvote please help
â Sydney
49 mins ago
2
please see my answer below and upvote from me ;-)
â Goro
48 mins ago
Sorry but this is not a scripting service. If you do not know any shell scripting, you'd start learning.
â andcoz
48 mins ago
6
@andcoz i don't like programming and it is not my hobby, I have problem and I need help what is wrong with that?
â Sydney
46 mins ago
1
Sydney: The problem is that this site teaches people programming. If you don't care about the "how", pay someone to solve the problem for you.
â choroba
36 mins ago
 |Â
show 1 more comment
6
why downvote please help
â Sydney
49 mins ago
2
please see my answer below and upvote from me ;-)
â Goro
48 mins ago
Sorry but this is not a scripting service. If you do not know any shell scripting, you'd start learning.
â andcoz
48 mins ago
6
@andcoz i don't like programming and it is not my hobby, I have problem and I need help what is wrong with that?
â Sydney
46 mins ago
1
Sydney: The problem is that this site teaches people programming. If you don't care about the "how", pay someone to solve the problem for you.
â choroba
36 mins ago
6
6
why downvote please help
â Sydney
49 mins ago
why downvote please help
â Sydney
49 mins ago
2
2
please see my answer below and upvote from me ;-)
â Goro
48 mins ago
please see my answer below and upvote from me ;-)
â Goro
48 mins ago
Sorry but this is not a scripting service. If you do not know any shell scripting, you'd start learning.
â andcoz
48 mins ago
Sorry but this is not a scripting service. If you do not know any shell scripting, you'd start learning.
â andcoz
48 mins ago
6
6
@andcoz i don't like programming and it is not my hobby, I have problem and I need help what is wrong with that?
â Sydney
46 mins ago
@andcoz i don't like programming and it is not my hobby, I have problem and I need help what is wrong with that?
â Sydney
46 mins ago
1
1
Sydney: The problem is that this site teaches people programming. If you don't care about the "how", pay someone to solve the problem for you.
â choroba
36 mins ago
Sydney: The problem is that this site teaches people programming. If you don't care about the "how", pay someone to solve the problem for you.
â choroba
36 mins ago
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
6
down vote
accepted
You can do it this way:
<file sed 's/./&*/g;s/*$//' | bc
7408800
0
0
0
5040
564480
72
0
0
20160
20160
6720
With GNU sed
, that can be simplified as:
<file sed 's/./*&/2g' | bc
1
thank you for help!
â Sydney
44 mins ago
@Stéphane Chazelas. thank you very much ;-)
â Goro
38 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
You can do it this way:
<file sed 's/./&*/g;s/*$//' | bc
7408800
0
0
0
5040
564480
72
0
0
20160
20160
6720
With GNU sed
, that can be simplified as:
<file sed 's/./*&/2g' | bc
1
thank you for help!
â Sydney
44 mins ago
@Stéphane Chazelas. thank you very much ;-)
â Goro
38 mins ago
add a comment |Â
up vote
6
down vote
accepted
You can do it this way:
<file sed 's/./&*/g;s/*$//' | bc
7408800
0
0
0
5040
564480
72
0
0
20160
20160
6720
With GNU sed
, that can be simplified as:
<file sed 's/./*&/2g' | bc
1
thank you for help!
â Sydney
44 mins ago
@Stéphane Chazelas. thank you very much ;-)
â Goro
38 mins ago
add a comment |Â
up vote
6
down vote
accepted
up vote
6
down vote
accepted
You can do it this way:
<file sed 's/./&*/g;s/*$//' | bc
7408800
0
0
0
5040
564480
72
0
0
20160
20160
6720
With GNU sed
, that can be simplified as:
<file sed 's/./*&/2g' | bc
You can do it this way:
<file sed 's/./&*/g;s/*$//' | bc
7408800
0
0
0
5040
564480
72
0
0
20160
20160
6720
With GNU sed
, that can be simplified as:
<file sed 's/./*&/2g' | bc
edited 39 mins ago
Stéphane Chazelas
287k53531868
287k53531868
answered 48 mins ago
Goro
7,54253270
7,54253270
1
thank you for help!
â Sydney
44 mins ago
@Stéphane Chazelas. thank you very much ;-)
â Goro
38 mins ago
add a comment |Â
1
thank you for help!
â Sydney
44 mins ago
@Stéphane Chazelas. thank you very much ;-)
â Goro
38 mins ago
1
1
thank you for help!
â Sydney
44 mins ago
thank you for help!
â Sydney
44 mins ago
@Stéphane Chazelas. thank you very much ;-)
â Goro
38 mins ago
@Stéphane Chazelas. thank you very much ;-)
â Goro
38 mins ago
add a comment |Â
Sydney is a new contributor. Be nice, and check out our Code of Conduct.
Sydney is a new contributor. Be nice, and check out our Code of Conduct.
Sydney is a new contributor. Be nice, and check out our Code of Conduct.
Sydney is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474021%2fmultiply-digits-within-a-number-with-each-other%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
6
why downvote please help
â Sydney
49 mins ago
2
please see my answer below and upvote from me ;-)
â Goro
48 mins ago
Sorry but this is not a scripting service. If you do not know any shell scripting, you'd start learning.
â andcoz
48 mins ago
6
@andcoz i don't like programming and it is not my hobby, I have problem and I need help what is wrong with that?
â Sydney
46 mins ago
1
Sydney: The problem is that this site teaches people programming. If you don't care about the "how", pay someone to solve the problem for you.
â choroba
36 mins ago