How to iterate through an array of numbers in shell-script?
I am trying to iterate through an array created after some command execution.
The code used is:
#!/bin/bash
mailx -H|grep '^ [UN]'>ListOfMessages.txt
msgNumbers=`cut -c 4-5 ListOfMessages.txt`
echo $msgNumbers
for msg in "${msgNumbers[@]}";
do
echo $msg;
echo $msg|mailx;
done
The ListOfMessages.txt look like:
U 5 Sender1 Thu Aug 23 14:28 179/10454 Incident
U 7 Sender2 Thu Aug 23 15:20 179/10456 Incident
U 8 Sender3 Thu Aug 23 15:41 192/10801 Incident
N 9 Sender4 Thu Aug 23 15:45 197/11011 Incident
The array is getting updated with the numbers 5 7 8 9 as required.
I keep getting "Bad Substitution" error(at the line where for loop starts).
Please advise me on the she-bang to be used.
shell-script array
add a comment |
I am trying to iterate through an array created after some command execution.
The code used is:
#!/bin/bash
mailx -H|grep '^ [UN]'>ListOfMessages.txt
msgNumbers=`cut -c 4-5 ListOfMessages.txt`
echo $msgNumbers
for msg in "${msgNumbers[@]}";
do
echo $msg;
echo $msg|mailx;
done
The ListOfMessages.txt look like:
U 5 Sender1 Thu Aug 23 14:28 179/10454 Incident
U 7 Sender2 Thu Aug 23 15:20 179/10456 Incident
U 8 Sender3 Thu Aug 23 15:41 192/10801 Incident
N 9 Sender4 Thu Aug 23 15:45 197/11011 Incident
The array is getting updated with the numbers 5 7 8 9 as required.
I keep getting "Bad Substitution" error(at the line where for loop starts).
Please advise me on the she-bang to be used.
shell-script array
It seems to be a follow-up on How can we store the output of a command as an array in Unix shell script?.
– Stéphane Chazelas
Aug 23 '18 at 10:36
add a comment |
I am trying to iterate through an array created after some command execution.
The code used is:
#!/bin/bash
mailx -H|grep '^ [UN]'>ListOfMessages.txt
msgNumbers=`cut -c 4-5 ListOfMessages.txt`
echo $msgNumbers
for msg in "${msgNumbers[@]}";
do
echo $msg;
echo $msg|mailx;
done
The ListOfMessages.txt look like:
U 5 Sender1 Thu Aug 23 14:28 179/10454 Incident
U 7 Sender2 Thu Aug 23 15:20 179/10456 Incident
U 8 Sender3 Thu Aug 23 15:41 192/10801 Incident
N 9 Sender4 Thu Aug 23 15:45 197/11011 Incident
The array is getting updated with the numbers 5 7 8 9 as required.
I keep getting "Bad Substitution" error(at the line where for loop starts).
Please advise me on the she-bang to be used.
shell-script array
I am trying to iterate through an array created after some command execution.
The code used is:
#!/bin/bash
mailx -H|grep '^ [UN]'>ListOfMessages.txt
msgNumbers=`cut -c 4-5 ListOfMessages.txt`
echo $msgNumbers
for msg in "${msgNumbers[@]}";
do
echo $msg;
echo $msg|mailx;
done
The ListOfMessages.txt look like:
U 5 Sender1 Thu Aug 23 14:28 179/10454 Incident
U 7 Sender2 Thu Aug 23 15:20 179/10456 Incident
U 8 Sender3 Thu Aug 23 15:41 192/10801 Incident
N 9 Sender4 Thu Aug 23 15:45 197/11011 Incident
The array is getting updated with the numbers 5 7 8 9 as required.
I keep getting "Bad Substitution" error(at the line where for loop starts).
Please advise me on the she-bang to be used.
shell-script array
shell-script array
edited Sep 13 '18 at 15:04
Rui F Ribeiro
39.1k1479130
39.1k1479130
asked Aug 23 '18 at 7:13
Devjith
4517
4517
It seems to be a follow-up on How can we store the output of a command as an array in Unix shell script?.
– Stéphane Chazelas
Aug 23 '18 at 10:36
add a comment |
It seems to be a follow-up on How can we store the output of a command as an array in Unix shell script?.
– Stéphane Chazelas
Aug 23 '18 at 10:36
It seems to be a follow-up on How can we store the output of a command as an array in Unix shell script?.
– Stéphane Chazelas
Aug 23 '18 at 10:36
It seems to be a follow-up on How can we store the output of a command as an array in Unix shell script?.
– Stéphane Chazelas
Aug 23 '18 at 10:36
add a comment |
4 Answers
4
active
oldest
votes
As far as I can see, you have no array in your code. The variable msgNumbers
is a string that holds the output of your cut
command.
To iterate over the output of cut
, use
#!/bin/bash
mailx -H | grep '^ [UN]' | cut -c 4-5 |
while read msg; do
print 'msg = %ss' "$msg"
done
This sends the output of cut
into the while
loop immediately following it, through the pipe (|
). The while
loop will iterate with msg
set to each individual line of output from cut
.
The cut
gets its data directly from the grep
command, which removes the need for storing the data in an intermediate file or variable.
I removed the echo $msg|mailx;
command because it did not make much sense to me (the mailx
utility needs an address to send the data to).
The grep
+cut
could also be replaced by a single call to awk
where we let awk
do the work of both tools and output the second whitespace-delimited column when the regular expression matches:
#!/bin/bash
mailx -H | awk '/^ [UN]/ { print $2 }' |
while read msg; do
print 'msg = %ss' "$msg"
done
I'm not commenting further on the use of mailx
as it is a non-standard utility which is implemented slightly differently across Unix systems (my version does not have a -H
option, for example).
The #!
-line looks ok to me, if you want the script to be executed by bash
and if the bash
executable is located at that path (which it commonly is on Linux systems, for example, but check with command -v bash
on your system to be sure). The code I have posted above is compatible with /bin/sh
, so bash
isn't really needed to run it (it would run in any sh
-like shell).
Just make sure that the script is executable and that you run it without specifying an explicit interpreter.
The OP's probably on Solaris (10 or older) as they get Bourne shell error messages.
– Stéphane Chazelas
Aug 23 '18 at 9:02
add a comment |
Don't double quote the msgNumbers reference, and, msgNumbers is not an array, so the indexing is pointless.
okay...then can you advise me how to store the result of command: cut -c 4-5 ListOfMessages.txt so that I can use the values one by one in a loop?
– Devjith
Aug 23 '18 at 7:19
The first half tells how to make the for loop work, and the second half hints on improvement. Had the requestor given the input sample from the beginning, a more detailed answer (or even full blown solution) could have benn provided.
– RudiC
Aug 23 '18 at 9:54
add a comment |
Use ()
to store the value as an array.
msgNumbers=(`cut -c 4-5 ListOfMessages.txt`)
echo "${msgNumbers[@]}"
for msg in "${msgNumbers[@]}";
do
echo $msg;
done
Tried with your answer....But getting an error: Shell_script.sh: syntax error at line 4: `msgNumbers=' unexpected
– Devjith
Aug 23 '18 at 7:41
@Devjith, again, you've tried to interpret the script withsh
, notbash
. Don't run the script assh the-script
. Do achmod a+x the-script
and then./the-script
– Stéphane Chazelas
Aug 23 '18 at 9:00
add a comment |
The issue is solved.
The problem was that msgNumbers was not an indexed array. So I changed the for msg in "${msgNumbers[@]}";
to for msg in ${msgNumbers};
.Now its working. The rest of the code is same as in my question.
It's still not an array, and now you rely on the shell doing word splitting of the string in your variable, and filename generation ("globbing") on the words generated by the word splitting. Your code would now break if theIFS
variable is set to one or several digits.
– Kusalananda
Aug 23 '18 at 9:00
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f464313%2fhow-to-iterate-through-an-array-of-numbers-in-shell-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
As far as I can see, you have no array in your code. The variable msgNumbers
is a string that holds the output of your cut
command.
To iterate over the output of cut
, use
#!/bin/bash
mailx -H | grep '^ [UN]' | cut -c 4-5 |
while read msg; do
print 'msg = %ss' "$msg"
done
This sends the output of cut
into the while
loop immediately following it, through the pipe (|
). The while
loop will iterate with msg
set to each individual line of output from cut
.
The cut
gets its data directly from the grep
command, which removes the need for storing the data in an intermediate file or variable.
I removed the echo $msg|mailx;
command because it did not make much sense to me (the mailx
utility needs an address to send the data to).
The grep
+cut
could also be replaced by a single call to awk
where we let awk
do the work of both tools and output the second whitespace-delimited column when the regular expression matches:
#!/bin/bash
mailx -H | awk '/^ [UN]/ { print $2 }' |
while read msg; do
print 'msg = %ss' "$msg"
done
I'm not commenting further on the use of mailx
as it is a non-standard utility which is implemented slightly differently across Unix systems (my version does not have a -H
option, for example).
The #!
-line looks ok to me, if you want the script to be executed by bash
and if the bash
executable is located at that path (which it commonly is on Linux systems, for example, but check with command -v bash
on your system to be sure). The code I have posted above is compatible with /bin/sh
, so bash
isn't really needed to run it (it would run in any sh
-like shell).
Just make sure that the script is executable and that you run it without specifying an explicit interpreter.
The OP's probably on Solaris (10 or older) as they get Bourne shell error messages.
– Stéphane Chazelas
Aug 23 '18 at 9:02
add a comment |
As far as I can see, you have no array in your code. The variable msgNumbers
is a string that holds the output of your cut
command.
To iterate over the output of cut
, use
#!/bin/bash
mailx -H | grep '^ [UN]' | cut -c 4-5 |
while read msg; do
print 'msg = %ss' "$msg"
done
This sends the output of cut
into the while
loop immediately following it, through the pipe (|
). The while
loop will iterate with msg
set to each individual line of output from cut
.
The cut
gets its data directly from the grep
command, which removes the need for storing the data in an intermediate file or variable.
I removed the echo $msg|mailx;
command because it did not make much sense to me (the mailx
utility needs an address to send the data to).
The grep
+cut
could also be replaced by a single call to awk
where we let awk
do the work of both tools and output the second whitespace-delimited column when the regular expression matches:
#!/bin/bash
mailx -H | awk '/^ [UN]/ { print $2 }' |
while read msg; do
print 'msg = %ss' "$msg"
done
I'm not commenting further on the use of mailx
as it is a non-standard utility which is implemented slightly differently across Unix systems (my version does not have a -H
option, for example).
The #!
-line looks ok to me, if you want the script to be executed by bash
and if the bash
executable is located at that path (which it commonly is on Linux systems, for example, but check with command -v bash
on your system to be sure). The code I have posted above is compatible with /bin/sh
, so bash
isn't really needed to run it (it would run in any sh
-like shell).
Just make sure that the script is executable and that you run it without specifying an explicit interpreter.
The OP's probably on Solaris (10 or older) as they get Bourne shell error messages.
– Stéphane Chazelas
Aug 23 '18 at 9:02
add a comment |
As far as I can see, you have no array in your code. The variable msgNumbers
is a string that holds the output of your cut
command.
To iterate over the output of cut
, use
#!/bin/bash
mailx -H | grep '^ [UN]' | cut -c 4-5 |
while read msg; do
print 'msg = %ss' "$msg"
done
This sends the output of cut
into the while
loop immediately following it, through the pipe (|
). The while
loop will iterate with msg
set to each individual line of output from cut
.
The cut
gets its data directly from the grep
command, which removes the need for storing the data in an intermediate file or variable.
I removed the echo $msg|mailx;
command because it did not make much sense to me (the mailx
utility needs an address to send the data to).
The grep
+cut
could also be replaced by a single call to awk
where we let awk
do the work of both tools and output the second whitespace-delimited column when the regular expression matches:
#!/bin/bash
mailx -H | awk '/^ [UN]/ { print $2 }' |
while read msg; do
print 'msg = %ss' "$msg"
done
I'm not commenting further on the use of mailx
as it is a non-standard utility which is implemented slightly differently across Unix systems (my version does not have a -H
option, for example).
The #!
-line looks ok to me, if you want the script to be executed by bash
and if the bash
executable is located at that path (which it commonly is on Linux systems, for example, but check with command -v bash
on your system to be sure). The code I have posted above is compatible with /bin/sh
, so bash
isn't really needed to run it (it would run in any sh
-like shell).
Just make sure that the script is executable and that you run it without specifying an explicit interpreter.
As far as I can see, you have no array in your code. The variable msgNumbers
is a string that holds the output of your cut
command.
To iterate over the output of cut
, use
#!/bin/bash
mailx -H | grep '^ [UN]' | cut -c 4-5 |
while read msg; do
print 'msg = %ss' "$msg"
done
This sends the output of cut
into the while
loop immediately following it, through the pipe (|
). The while
loop will iterate with msg
set to each individual line of output from cut
.
The cut
gets its data directly from the grep
command, which removes the need for storing the data in an intermediate file or variable.
I removed the echo $msg|mailx;
command because it did not make much sense to me (the mailx
utility needs an address to send the data to).
The grep
+cut
could also be replaced by a single call to awk
where we let awk
do the work of both tools and output the second whitespace-delimited column when the regular expression matches:
#!/bin/bash
mailx -H | awk '/^ [UN]/ { print $2 }' |
while read msg; do
print 'msg = %ss' "$msg"
done
I'm not commenting further on the use of mailx
as it is a non-standard utility which is implemented slightly differently across Unix systems (my version does not have a -H
option, for example).
The #!
-line looks ok to me, if you want the script to be executed by bash
and if the bash
executable is located at that path (which it commonly is on Linux systems, for example, but check with command -v bash
on your system to be sure). The code I have posted above is compatible with /bin/sh
, so bash
isn't really needed to run it (it would run in any sh
-like shell).
Just make sure that the script is executable and that you run it without specifying an explicit interpreter.
edited Dec 20 '18 at 16:48
answered Aug 23 '18 at 7:20
Kusalananda
122k16229374
122k16229374
The OP's probably on Solaris (10 or older) as they get Bourne shell error messages.
– Stéphane Chazelas
Aug 23 '18 at 9:02
add a comment |
The OP's probably on Solaris (10 or older) as they get Bourne shell error messages.
– Stéphane Chazelas
Aug 23 '18 at 9:02
The OP's probably on Solaris (10 or older) as they get Bourne shell error messages.
– Stéphane Chazelas
Aug 23 '18 at 9:02
The OP's probably on Solaris (10 or older) as they get Bourne shell error messages.
– Stéphane Chazelas
Aug 23 '18 at 9:02
add a comment |
Don't double quote the msgNumbers reference, and, msgNumbers is not an array, so the indexing is pointless.
okay...then can you advise me how to store the result of command: cut -c 4-5 ListOfMessages.txt so that I can use the values one by one in a loop?
– Devjith
Aug 23 '18 at 7:19
The first half tells how to make the for loop work, and the second half hints on improvement. Had the requestor given the input sample from the beginning, a more detailed answer (or even full blown solution) could have benn provided.
– RudiC
Aug 23 '18 at 9:54
add a comment |
Don't double quote the msgNumbers reference, and, msgNumbers is not an array, so the indexing is pointless.
okay...then can you advise me how to store the result of command: cut -c 4-5 ListOfMessages.txt so that I can use the values one by one in a loop?
– Devjith
Aug 23 '18 at 7:19
The first half tells how to make the for loop work, and the second half hints on improvement. Had the requestor given the input sample from the beginning, a more detailed answer (or even full blown solution) could have benn provided.
– RudiC
Aug 23 '18 at 9:54
add a comment |
Don't double quote the msgNumbers reference, and, msgNumbers is not an array, so the indexing is pointless.
Don't double quote the msgNumbers reference, and, msgNumbers is not an array, so the indexing is pointless.
answered Aug 23 '18 at 7:17
RudiC
4,2041312
4,2041312
okay...then can you advise me how to store the result of command: cut -c 4-5 ListOfMessages.txt so that I can use the values one by one in a loop?
– Devjith
Aug 23 '18 at 7:19
The first half tells how to make the for loop work, and the second half hints on improvement. Had the requestor given the input sample from the beginning, a more detailed answer (or even full blown solution) could have benn provided.
– RudiC
Aug 23 '18 at 9:54
add a comment |
okay...then can you advise me how to store the result of command: cut -c 4-5 ListOfMessages.txt so that I can use the values one by one in a loop?
– Devjith
Aug 23 '18 at 7:19
The first half tells how to make the for loop work, and the second half hints on improvement. Had the requestor given the input sample from the beginning, a more detailed answer (or even full blown solution) could have benn provided.
– RudiC
Aug 23 '18 at 9:54
okay...then can you advise me how to store the result of command: cut -c 4-5 ListOfMessages.txt so that I can use the values one by one in a loop?
– Devjith
Aug 23 '18 at 7:19
okay...then can you advise me how to store the result of command: cut -c 4-5 ListOfMessages.txt so that I can use the values one by one in a loop?
– Devjith
Aug 23 '18 at 7:19
The first half tells how to make the for loop work, and the second half hints on improvement. Had the requestor given the input sample from the beginning, a more detailed answer (or even full blown solution) could have benn provided.
– RudiC
Aug 23 '18 at 9:54
The first half tells how to make the for loop work, and the second half hints on improvement. Had the requestor given the input sample from the beginning, a more detailed answer (or even full blown solution) could have benn provided.
– RudiC
Aug 23 '18 at 9:54
add a comment |
Use ()
to store the value as an array.
msgNumbers=(`cut -c 4-5 ListOfMessages.txt`)
echo "${msgNumbers[@]}"
for msg in "${msgNumbers[@]}";
do
echo $msg;
done
Tried with your answer....But getting an error: Shell_script.sh: syntax error at line 4: `msgNumbers=' unexpected
– Devjith
Aug 23 '18 at 7:41
@Devjith, again, you've tried to interpret the script withsh
, notbash
. Don't run the script assh the-script
. Do achmod a+x the-script
and then./the-script
– Stéphane Chazelas
Aug 23 '18 at 9:00
add a comment |
Use ()
to store the value as an array.
msgNumbers=(`cut -c 4-5 ListOfMessages.txt`)
echo "${msgNumbers[@]}"
for msg in "${msgNumbers[@]}";
do
echo $msg;
done
Tried with your answer....But getting an error: Shell_script.sh: syntax error at line 4: `msgNumbers=' unexpected
– Devjith
Aug 23 '18 at 7:41
@Devjith, again, you've tried to interpret the script withsh
, notbash
. Don't run the script assh the-script
. Do achmod a+x the-script
and then./the-script
– Stéphane Chazelas
Aug 23 '18 at 9:00
add a comment |
Use ()
to store the value as an array.
msgNumbers=(`cut -c 4-5 ListOfMessages.txt`)
echo "${msgNumbers[@]}"
for msg in "${msgNumbers[@]}";
do
echo $msg;
done
Use ()
to store the value as an array.
msgNumbers=(`cut -c 4-5 ListOfMessages.txt`)
echo "${msgNumbers[@]}"
for msg in "${msgNumbers[@]}";
do
echo $msg;
done
answered Aug 23 '18 at 7:22
msp9011
3,78343863
3,78343863
Tried with your answer....But getting an error: Shell_script.sh: syntax error at line 4: `msgNumbers=' unexpected
– Devjith
Aug 23 '18 at 7:41
@Devjith, again, you've tried to interpret the script withsh
, notbash
. Don't run the script assh the-script
. Do achmod a+x the-script
and then./the-script
– Stéphane Chazelas
Aug 23 '18 at 9:00
add a comment |
Tried with your answer....But getting an error: Shell_script.sh: syntax error at line 4: `msgNumbers=' unexpected
– Devjith
Aug 23 '18 at 7:41
@Devjith, again, you've tried to interpret the script withsh
, notbash
. Don't run the script assh the-script
. Do achmod a+x the-script
and then./the-script
– Stéphane Chazelas
Aug 23 '18 at 9:00
Tried with your answer....But getting an error: Shell_script.sh: syntax error at line 4: `msgNumbers=' unexpected
– Devjith
Aug 23 '18 at 7:41
Tried with your answer....But getting an error: Shell_script.sh: syntax error at line 4: `msgNumbers=' unexpected
– Devjith
Aug 23 '18 at 7:41
@Devjith, again, you've tried to interpret the script with
sh
, not bash
. Don't run the script as sh the-script
. Do a chmod a+x the-script
and then ./the-script
– Stéphane Chazelas
Aug 23 '18 at 9:00
@Devjith, again, you've tried to interpret the script with
sh
, not bash
. Don't run the script as sh the-script
. Do a chmod a+x the-script
and then ./the-script
– Stéphane Chazelas
Aug 23 '18 at 9:00
add a comment |
The issue is solved.
The problem was that msgNumbers was not an indexed array. So I changed the for msg in "${msgNumbers[@]}";
to for msg in ${msgNumbers};
.Now its working. The rest of the code is same as in my question.
It's still not an array, and now you rely on the shell doing word splitting of the string in your variable, and filename generation ("globbing") on the words generated by the word splitting. Your code would now break if theIFS
variable is set to one or several digits.
– Kusalananda
Aug 23 '18 at 9:00
add a comment |
The issue is solved.
The problem was that msgNumbers was not an indexed array. So I changed the for msg in "${msgNumbers[@]}";
to for msg in ${msgNumbers};
.Now its working. The rest of the code is same as in my question.
It's still not an array, and now you rely on the shell doing word splitting of the string in your variable, and filename generation ("globbing") on the words generated by the word splitting. Your code would now break if theIFS
variable is set to one or several digits.
– Kusalananda
Aug 23 '18 at 9:00
add a comment |
The issue is solved.
The problem was that msgNumbers was not an indexed array. So I changed the for msg in "${msgNumbers[@]}";
to for msg in ${msgNumbers};
.Now its working. The rest of the code is same as in my question.
The issue is solved.
The problem was that msgNumbers was not an indexed array. So I changed the for msg in "${msgNumbers[@]}";
to for msg in ${msgNumbers};
.Now its working. The rest of the code is same as in my question.
answered Aug 23 '18 at 8:56
Devjith
4517
4517
It's still not an array, and now you rely on the shell doing word splitting of the string in your variable, and filename generation ("globbing") on the words generated by the word splitting. Your code would now break if theIFS
variable is set to one or several digits.
– Kusalananda
Aug 23 '18 at 9:00
add a comment |
It's still not an array, and now you rely on the shell doing word splitting of the string in your variable, and filename generation ("globbing") on the words generated by the word splitting. Your code would now break if theIFS
variable is set to one or several digits.
– Kusalananda
Aug 23 '18 at 9:00
It's still not an array, and now you rely on the shell doing word splitting of the string in your variable, and filename generation ("globbing") on the words generated by the word splitting. Your code would now break if the
IFS
variable is set to one or several digits.– Kusalananda
Aug 23 '18 at 9:00
It's still not an array, and now you rely on the shell doing word splitting of the string in your variable, and filename generation ("globbing") on the words generated by the word splitting. Your code would now break if the
IFS
variable is set to one or several digits.– Kusalananda
Aug 23 '18 at 9:00
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f464313%2fhow-to-iterate-through-an-array-of-numbers-in-shell-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
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
It seems to be a follow-up on How can we store the output of a command as an array in Unix shell script?.
– Stéphane Chazelas
Aug 23 '18 at 10:36