Somehow I created a nondeterministic sh script
I created the following script:
#!bin/bash
cat > Top10 <<EOF
Linux Mint 17.2
Ubuntu 15.10
Debian GNU/Linux 8.2
Mageria 5
Fedora 23
openSUSE Leap 42.1
Arch Linux
CentOS 7.2-1511
PCLinuxOS 2014.12
Slackware Linux 14.1
FreeBSD
EOF
sed -ri "s/^[^0-9]*$//" Top10
sed -r "s/(.*)([[:space:]][[:digit:]]*.*)$/21/" Top10 | sed -r "s/([[:space:]])([[:digit:]])/2/" | sed -r "s/([[:digit:]])([[:alpha:]])/1 2/" > Top10
sed -r -i "s/(.*)/L1/" Top10
sed -r -i "y/[aeiou]/[AEIOU]/" Top10
sort Top10 -g -o Top10
cat Top10
When I run it a few times the following happens:
As you can see sometimes the Top10 file turns out empty and sometimes it turn out the way I needed it to be. I know that the command which replaces the extensions from the end to the front of a line is done poorly. I ran this script on a VMware virtual machine. Could that be the reason?
command-line bash scripts sed text-processing
add a comment |
I created the following script:
#!bin/bash
cat > Top10 <<EOF
Linux Mint 17.2
Ubuntu 15.10
Debian GNU/Linux 8.2
Mageria 5
Fedora 23
openSUSE Leap 42.1
Arch Linux
CentOS 7.2-1511
PCLinuxOS 2014.12
Slackware Linux 14.1
FreeBSD
EOF
sed -ri "s/^[^0-9]*$//" Top10
sed -r "s/(.*)([[:space:]][[:digit:]]*.*)$/21/" Top10 | sed -r "s/([[:space:]])([[:digit:]])/2/" | sed -r "s/([[:digit:]])([[:alpha:]])/1 2/" > Top10
sed -r -i "s/(.*)/L1/" Top10
sed -r -i "y/[aeiou]/[AEIOU]/" Top10
sort Top10 -g -o Top10
cat Top10
When I run it a few times the following happens:
As you can see sometimes the Top10 file turns out empty and sometimes it turn out the way I needed it to be. I know that the command which replaces the extensions from the end to the front of a line is done poorly. I ran this script on a VMware virtual machine. Could that be the reason?
command-line bash scripts sed text-processing
I'm flagging to close this question as off-topic because as it currently stands, it's not about Ubuntu within the scope as defined in the help center. Please edit your question to help explain what your ubuntu-specific problem or question is.
– cat
Jan 9 '16 at 15:58
If you have a question about GNU Sed or shell scripting in general, you may be able to get help at Unix & Linux.
– cat
Jan 9 '16 at 15:58
1
Another thing to notice: You shouldn't typesh zadatak3.sh
to invoke the script. Typing the name of the shell on the command line when invoking a script is not the proper way to invoke a script. The correct place to indicate which shell to use is the#!
line at the start of the script. You shouldn't be overriding that. You should have typed./zadatak3.sh
instead.
– kasperd
Jan 9 '16 at 23:17
add a comment |
I created the following script:
#!bin/bash
cat > Top10 <<EOF
Linux Mint 17.2
Ubuntu 15.10
Debian GNU/Linux 8.2
Mageria 5
Fedora 23
openSUSE Leap 42.1
Arch Linux
CentOS 7.2-1511
PCLinuxOS 2014.12
Slackware Linux 14.1
FreeBSD
EOF
sed -ri "s/^[^0-9]*$//" Top10
sed -r "s/(.*)([[:space:]][[:digit:]]*.*)$/21/" Top10 | sed -r "s/([[:space:]])([[:digit:]])/2/" | sed -r "s/([[:digit:]])([[:alpha:]])/1 2/" > Top10
sed -r -i "s/(.*)/L1/" Top10
sed -r -i "y/[aeiou]/[AEIOU]/" Top10
sort Top10 -g -o Top10
cat Top10
When I run it a few times the following happens:
As you can see sometimes the Top10 file turns out empty and sometimes it turn out the way I needed it to be. I know that the command which replaces the extensions from the end to the front of a line is done poorly. I ran this script on a VMware virtual machine. Could that be the reason?
command-line bash scripts sed text-processing
I created the following script:
#!bin/bash
cat > Top10 <<EOF
Linux Mint 17.2
Ubuntu 15.10
Debian GNU/Linux 8.2
Mageria 5
Fedora 23
openSUSE Leap 42.1
Arch Linux
CentOS 7.2-1511
PCLinuxOS 2014.12
Slackware Linux 14.1
FreeBSD
EOF
sed -ri "s/^[^0-9]*$//" Top10
sed -r "s/(.*)([[:space:]][[:digit:]]*.*)$/21/" Top10 | sed -r "s/([[:space:]])([[:digit:]])/2/" | sed -r "s/([[:digit:]])([[:alpha:]])/1 2/" > Top10
sed -r -i "s/(.*)/L1/" Top10
sed -r -i "y/[aeiou]/[AEIOU]/" Top10
sort Top10 -g -o Top10
cat Top10
When I run it a few times the following happens:
As you can see sometimes the Top10 file turns out empty and sometimes it turn out the way I needed it to be. I know that the command which replaces the extensions from the end to the front of a line is done poorly. I ran this script on a VMware virtual machine. Could that be the reason?
command-line bash scripts sed text-processing
command-line bash scripts sed text-processing
edited Jan 9 '16 at 16:39
muru
1
1
asked Jan 9 '16 at 15:50
GrgGrg
132
132
I'm flagging to close this question as off-topic because as it currently stands, it's not about Ubuntu within the scope as defined in the help center. Please edit your question to help explain what your ubuntu-specific problem or question is.
– cat
Jan 9 '16 at 15:58
If you have a question about GNU Sed or shell scripting in general, you may be able to get help at Unix & Linux.
– cat
Jan 9 '16 at 15:58
1
Another thing to notice: You shouldn't typesh zadatak3.sh
to invoke the script. Typing the name of the shell on the command line when invoking a script is not the proper way to invoke a script. The correct place to indicate which shell to use is the#!
line at the start of the script. You shouldn't be overriding that. You should have typed./zadatak3.sh
instead.
– kasperd
Jan 9 '16 at 23:17
add a comment |
I'm flagging to close this question as off-topic because as it currently stands, it's not about Ubuntu within the scope as defined in the help center. Please edit your question to help explain what your ubuntu-specific problem or question is.
– cat
Jan 9 '16 at 15:58
If you have a question about GNU Sed or shell scripting in general, you may be able to get help at Unix & Linux.
– cat
Jan 9 '16 at 15:58
1
Another thing to notice: You shouldn't typesh zadatak3.sh
to invoke the script. Typing the name of the shell on the command line when invoking a script is not the proper way to invoke a script. The correct place to indicate which shell to use is the#!
line at the start of the script. You shouldn't be overriding that. You should have typed./zadatak3.sh
instead.
– kasperd
Jan 9 '16 at 23:17
I'm flagging to close this question as off-topic because as it currently stands, it's not about Ubuntu within the scope as defined in the help center. Please edit your question to help explain what your ubuntu-specific problem or question is.
– cat
Jan 9 '16 at 15:58
I'm flagging to close this question as off-topic because as it currently stands, it's not about Ubuntu within the scope as defined in the help center. Please edit your question to help explain what your ubuntu-specific problem or question is.
– cat
Jan 9 '16 at 15:58
If you have a question about GNU Sed or shell scripting in general, you may be able to get help at Unix & Linux.
– cat
Jan 9 '16 at 15:58
If you have a question about GNU Sed or shell scripting in general, you may be able to get help at Unix & Linux.
– cat
Jan 9 '16 at 15:58
1
1
Another thing to notice: You shouldn't type
sh zadatak3.sh
to invoke the script. Typing the name of the shell on the command line when invoking a script is not the proper way to invoke a script. The correct place to indicate which shell to use is the #!
line at the start of the script. You shouldn't be overriding that. You should have typed ./zadatak3.sh
instead.– kasperd
Jan 9 '16 at 23:17
Another thing to notice: You shouldn't type
sh zadatak3.sh
to invoke the script. Typing the name of the shell on the command line when invoking a script is not the proper way to invoke a script. The correct place to indicate which shell to use is the #!
line at the start of the script. You shouldn't be overriding that. You should have typed ./zadatak3.sh
instead.– kasperd
Jan 9 '16 at 23:17
add a comment |
3 Answers
3
active
oldest
votes
More specifically, pipes are not deterministic.
I.e. in a pipe such as this one:
command1 file | command2 | command3 >file
it's not guaranteed that command1 file
will be executed before command3 >file
.
So the race condition between command1 file
and command3 >file
makes it so that sometimes the file is first read by command1 file
and sometimes the file is first truncated by command3 >file
, giving the expected output in the first case and a giving an empty output in the second case.
This can be fixed by using sponge
(in the moreutils
package) to write the output to the file, to make sure that the output gets written to the file only after the rest of the pipe has finished executing:
command1 file | command2 | command3 | sponge file
2
I think one possible solution in addition to that would be to turn sed commands into one single script , instead of piping it over and over.
– Sergiy Kolodyazhnyy
Jan 9 '16 at 19:00
@Serg Sure. Actually that would be the way to go (my answer only wanted to address why the problem showed up and how to fix simlar problems in general). In this specific case the way to go is muru's answer.
– kos
Jan 10 '16 at 5:30
@StenSoft Since every command of the pipe is run in a subshell, each redirection is resolved by a different subshell, and since the order in which the subshells are to be run is not defined, there's a race condition between the first and the last command: runningfor((i=0;i<20;i++)); do echo foo >file | echo bar >file; cat file; done
should be enough to be convinced of that.
– kos
Jan 12 '16 at 18:18
@StenSoft I'm afraid it's often but not always: paste.ubuntu.com/14479882. You problem is being convinced that the redirections are always resolved first. That is true for a single command, but not for commands in a pipe: in that case the resolution of the redirections for each single command is delegated to the subshell that executes the command.
– kos
Jan 12 '16 at 18:58
add a comment |
sed -r "s/(.*)([[:space:]][[:digit:]]*.*)$/21/" Top10 | sed -r "s/([[:space:]])([[:digit:]])/2/" | sed -r "s/([[:digit:]])([[:alpha:]])/1 2/" > Top10
causes the file to be first overwritten with > Top10
and only then processed by sed
(the file is empty at that time)
add a comment |
There is no reason to run 6 sed commands when you can do it in one:
sed -ri 's/^[^0-9]*$//; s/(.*)/L1/; y/[aeiou]/[AEIOU]/; s/(.*)([[:space:]])([[:digit:]]*.*)$/3 1/' Top10
Note, in particular, how the second pipe of sed commands could be combined into one expression if you just grouped your matches differently. Since you wanted to discard the leading whitespace anyway, and then add a space after the version, you could do that in the original match itself, by grouping the leading space and the version separately.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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
});
}
});
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%2faskubuntu.com%2fquestions%2f719081%2fsomehow-i-created-a-nondeterministic-sh-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
More specifically, pipes are not deterministic.
I.e. in a pipe such as this one:
command1 file | command2 | command3 >file
it's not guaranteed that command1 file
will be executed before command3 >file
.
So the race condition between command1 file
and command3 >file
makes it so that sometimes the file is first read by command1 file
and sometimes the file is first truncated by command3 >file
, giving the expected output in the first case and a giving an empty output in the second case.
This can be fixed by using sponge
(in the moreutils
package) to write the output to the file, to make sure that the output gets written to the file only after the rest of the pipe has finished executing:
command1 file | command2 | command3 | sponge file
2
I think one possible solution in addition to that would be to turn sed commands into one single script , instead of piping it over and over.
– Sergiy Kolodyazhnyy
Jan 9 '16 at 19:00
@Serg Sure. Actually that would be the way to go (my answer only wanted to address why the problem showed up and how to fix simlar problems in general). In this specific case the way to go is muru's answer.
– kos
Jan 10 '16 at 5:30
@StenSoft Since every command of the pipe is run in a subshell, each redirection is resolved by a different subshell, and since the order in which the subshells are to be run is not defined, there's a race condition between the first and the last command: runningfor((i=0;i<20;i++)); do echo foo >file | echo bar >file; cat file; done
should be enough to be convinced of that.
– kos
Jan 12 '16 at 18:18
@StenSoft I'm afraid it's often but not always: paste.ubuntu.com/14479882. You problem is being convinced that the redirections are always resolved first. That is true for a single command, but not for commands in a pipe: in that case the resolution of the redirections for each single command is delegated to the subshell that executes the command.
– kos
Jan 12 '16 at 18:58
add a comment |
More specifically, pipes are not deterministic.
I.e. in a pipe such as this one:
command1 file | command2 | command3 >file
it's not guaranteed that command1 file
will be executed before command3 >file
.
So the race condition between command1 file
and command3 >file
makes it so that sometimes the file is first read by command1 file
and sometimes the file is first truncated by command3 >file
, giving the expected output in the first case and a giving an empty output in the second case.
This can be fixed by using sponge
(in the moreutils
package) to write the output to the file, to make sure that the output gets written to the file only after the rest of the pipe has finished executing:
command1 file | command2 | command3 | sponge file
2
I think one possible solution in addition to that would be to turn sed commands into one single script , instead of piping it over and over.
– Sergiy Kolodyazhnyy
Jan 9 '16 at 19:00
@Serg Sure. Actually that would be the way to go (my answer only wanted to address why the problem showed up and how to fix simlar problems in general). In this specific case the way to go is muru's answer.
– kos
Jan 10 '16 at 5:30
@StenSoft Since every command of the pipe is run in a subshell, each redirection is resolved by a different subshell, and since the order in which the subshells are to be run is not defined, there's a race condition between the first and the last command: runningfor((i=0;i<20;i++)); do echo foo >file | echo bar >file; cat file; done
should be enough to be convinced of that.
– kos
Jan 12 '16 at 18:18
@StenSoft I'm afraid it's often but not always: paste.ubuntu.com/14479882. You problem is being convinced that the redirections are always resolved first. That is true for a single command, but not for commands in a pipe: in that case the resolution of the redirections for each single command is delegated to the subshell that executes the command.
– kos
Jan 12 '16 at 18:58
add a comment |
More specifically, pipes are not deterministic.
I.e. in a pipe such as this one:
command1 file | command2 | command3 >file
it's not guaranteed that command1 file
will be executed before command3 >file
.
So the race condition between command1 file
and command3 >file
makes it so that sometimes the file is first read by command1 file
and sometimes the file is first truncated by command3 >file
, giving the expected output in the first case and a giving an empty output in the second case.
This can be fixed by using sponge
(in the moreutils
package) to write the output to the file, to make sure that the output gets written to the file only after the rest of the pipe has finished executing:
command1 file | command2 | command3 | sponge file
More specifically, pipes are not deterministic.
I.e. in a pipe such as this one:
command1 file | command2 | command3 >file
it's not guaranteed that command1 file
will be executed before command3 >file
.
So the race condition between command1 file
and command3 >file
makes it so that sometimes the file is first read by command1 file
and sometimes the file is first truncated by command3 >file
, giving the expected output in the first case and a giving an empty output in the second case.
This can be fixed by using sponge
(in the moreutils
package) to write the output to the file, to make sure that the output gets written to the file only after the rest of the pipe has finished executing:
command1 file | command2 | command3 | sponge file
edited Apr 13 '17 at 12:37
Community♦
1
1
answered Jan 9 '16 at 16:43
koskos
25.8k871121
25.8k871121
2
I think one possible solution in addition to that would be to turn sed commands into one single script , instead of piping it over and over.
– Sergiy Kolodyazhnyy
Jan 9 '16 at 19:00
@Serg Sure. Actually that would be the way to go (my answer only wanted to address why the problem showed up and how to fix simlar problems in general). In this specific case the way to go is muru's answer.
– kos
Jan 10 '16 at 5:30
@StenSoft Since every command of the pipe is run in a subshell, each redirection is resolved by a different subshell, and since the order in which the subshells are to be run is not defined, there's a race condition between the first and the last command: runningfor((i=0;i<20;i++)); do echo foo >file | echo bar >file; cat file; done
should be enough to be convinced of that.
– kos
Jan 12 '16 at 18:18
@StenSoft I'm afraid it's often but not always: paste.ubuntu.com/14479882. You problem is being convinced that the redirections are always resolved first. That is true for a single command, but not for commands in a pipe: in that case the resolution of the redirections for each single command is delegated to the subshell that executes the command.
– kos
Jan 12 '16 at 18:58
add a comment |
2
I think one possible solution in addition to that would be to turn sed commands into one single script , instead of piping it over and over.
– Sergiy Kolodyazhnyy
Jan 9 '16 at 19:00
@Serg Sure. Actually that would be the way to go (my answer only wanted to address why the problem showed up and how to fix simlar problems in general). In this specific case the way to go is muru's answer.
– kos
Jan 10 '16 at 5:30
@StenSoft Since every command of the pipe is run in a subshell, each redirection is resolved by a different subshell, and since the order in which the subshells are to be run is not defined, there's a race condition between the first and the last command: runningfor((i=0;i<20;i++)); do echo foo >file | echo bar >file; cat file; done
should be enough to be convinced of that.
– kos
Jan 12 '16 at 18:18
@StenSoft I'm afraid it's often but not always: paste.ubuntu.com/14479882. You problem is being convinced that the redirections are always resolved first. That is true for a single command, but not for commands in a pipe: in that case the resolution of the redirections for each single command is delegated to the subshell that executes the command.
– kos
Jan 12 '16 at 18:58
2
2
I think one possible solution in addition to that would be to turn sed commands into one single script , instead of piping it over and over.
– Sergiy Kolodyazhnyy
Jan 9 '16 at 19:00
I think one possible solution in addition to that would be to turn sed commands into one single script , instead of piping it over and over.
– Sergiy Kolodyazhnyy
Jan 9 '16 at 19:00
@Serg Sure. Actually that would be the way to go (my answer only wanted to address why the problem showed up and how to fix simlar problems in general). In this specific case the way to go is muru's answer.
– kos
Jan 10 '16 at 5:30
@Serg Sure. Actually that would be the way to go (my answer only wanted to address why the problem showed up and how to fix simlar problems in general). In this specific case the way to go is muru's answer.
– kos
Jan 10 '16 at 5:30
@StenSoft Since every command of the pipe is run in a subshell, each redirection is resolved by a different subshell, and since the order in which the subshells are to be run is not defined, there's a race condition between the first and the last command: running
for((i=0;i<20;i++)); do echo foo >file | echo bar >file; cat file; done
should be enough to be convinced of that.– kos
Jan 12 '16 at 18:18
@StenSoft Since every command of the pipe is run in a subshell, each redirection is resolved by a different subshell, and since the order in which the subshells are to be run is not defined, there's a race condition between the first and the last command: running
for((i=0;i<20;i++)); do echo foo >file | echo bar >file; cat file; done
should be enough to be convinced of that.– kos
Jan 12 '16 at 18:18
@StenSoft I'm afraid it's often but not always: paste.ubuntu.com/14479882. You problem is being convinced that the redirections are always resolved first. That is true for a single command, but not for commands in a pipe: in that case the resolution of the redirections for each single command is delegated to the subshell that executes the command.
– kos
Jan 12 '16 at 18:58
@StenSoft I'm afraid it's often but not always: paste.ubuntu.com/14479882. You problem is being convinced that the redirections are always resolved first. That is true for a single command, but not for commands in a pipe: in that case the resolution of the redirections for each single command is delegated to the subshell that executes the command.
– kos
Jan 12 '16 at 18:58
add a comment |
sed -r "s/(.*)([[:space:]][[:digit:]]*.*)$/21/" Top10 | sed -r "s/([[:space:]])([[:digit:]])/2/" | sed -r "s/([[:digit:]])([[:alpha:]])/1 2/" > Top10
causes the file to be first overwritten with > Top10
and only then processed by sed
(the file is empty at that time)
add a comment |
sed -r "s/(.*)([[:space:]][[:digit:]]*.*)$/21/" Top10 | sed -r "s/([[:space:]])([[:digit:]])/2/" | sed -r "s/([[:digit:]])([[:alpha:]])/1 2/" > Top10
causes the file to be first overwritten with > Top10
and only then processed by sed
(the file is empty at that time)
add a comment |
sed -r "s/(.*)([[:space:]][[:digit:]]*.*)$/21/" Top10 | sed -r "s/([[:space:]])([[:digit:]])/2/" | sed -r "s/([[:digit:]])([[:alpha:]])/1 2/" > Top10
causes the file to be first overwritten with > Top10
and only then processed by sed
(the file is empty at that time)
sed -r "s/(.*)([[:space:]][[:digit:]]*.*)$/21/" Top10 | sed -r "s/([[:space:]])([[:digit:]])/2/" | sed -r "s/([[:digit:]])([[:alpha:]])/1 2/" > Top10
causes the file to be first overwritten with > Top10
and only then processed by sed
(the file is empty at that time)
answered Jan 9 '16 at 16:32
StenSoftStenSoft
20614
20614
add a comment |
add a comment |
There is no reason to run 6 sed commands when you can do it in one:
sed -ri 's/^[^0-9]*$//; s/(.*)/L1/; y/[aeiou]/[AEIOU]/; s/(.*)([[:space:]])([[:digit:]]*.*)$/3 1/' Top10
Note, in particular, how the second pipe of sed commands could be combined into one expression if you just grouped your matches differently. Since you wanted to discard the leading whitespace anyway, and then add a space after the version, you could do that in the original match itself, by grouping the leading space and the version separately.
add a comment |
There is no reason to run 6 sed commands when you can do it in one:
sed -ri 's/^[^0-9]*$//; s/(.*)/L1/; y/[aeiou]/[AEIOU]/; s/(.*)([[:space:]])([[:digit:]]*.*)$/3 1/' Top10
Note, in particular, how the second pipe of sed commands could be combined into one expression if you just grouped your matches differently. Since you wanted to discard the leading whitespace anyway, and then add a space after the version, you could do that in the original match itself, by grouping the leading space and the version separately.
add a comment |
There is no reason to run 6 sed commands when you can do it in one:
sed -ri 's/^[^0-9]*$//; s/(.*)/L1/; y/[aeiou]/[AEIOU]/; s/(.*)([[:space:]])([[:digit:]]*.*)$/3 1/' Top10
Note, in particular, how the second pipe of sed commands could be combined into one expression if you just grouped your matches differently. Since you wanted to discard the leading whitespace anyway, and then add a space after the version, you could do that in the original match itself, by grouping the leading space and the version separately.
There is no reason to run 6 sed commands when you can do it in one:
sed -ri 's/^[^0-9]*$//; s/(.*)/L1/; y/[aeiou]/[AEIOU]/; s/(.*)([[:space:]])([[:digit:]]*.*)$/3 1/' Top10
Note, in particular, how the second pipe of sed commands could be combined into one expression if you just grouped your matches differently. Since you wanted to discard the leading whitespace anyway, and then add a space after the version, you could do that in the original match itself, by grouping the leading space and the version separately.
answered Jan 9 '16 at 16:43
murumuru
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f719081%2fsomehow-i-created-a-nondeterministic-sh-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
I'm flagging to close this question as off-topic because as it currently stands, it's not about Ubuntu within the scope as defined in the help center. Please edit your question to help explain what your ubuntu-specific problem or question is.
– cat
Jan 9 '16 at 15:58
If you have a question about GNU Sed or shell scripting in general, you may be able to get help at Unix & Linux.
– cat
Jan 9 '16 at 15:58
1
Another thing to notice: You shouldn't type
sh zadatak3.sh
to invoke the script. Typing the name of the shell on the command line when invoking a script is not the proper way to invoke a script. The correct place to indicate which shell to use is the#!
line at the start of the script. You shouldn't be overriding that. You should have typed./zadatak3.sh
instead.– kasperd
Jan 9 '16 at 23:17