Linux - Send Ctrl+C using linux/bash commands for specific shell scriptCan any shell do argument-level...
How do you calculate the range of an attack when attacking diagonally?
Translate English to Pig Latin | PIG_LATIN.PY
What's the difference between a share and a stock?
Round away from zero
How could a planet have one hemisphere way warmer than the other without the planet being tidally locked?
How does the UK House of Commons think they can prolong the deadline of Brexit?
'This one' as a pronoun
'Hard work never hurt anyone' Why not 'hurts'?
What is the difference between 「名前【なまえ】」 and 「名称【めいしょう】」?
Why does the seven segment display have decimal point at the right?
Identifying the following distribution
Was "The Hobbit" ever abridged?
Is there a way to retrieve the “source code” and the argument pattern from a macro for reuse (i.e. what show shows)?
How can I implement regular expressions on an embedded device?
Why did Boris Johnson call for new elections?
What's the eccentricity of an orbit (trajectory) falling straight down towards the center?
Are buttons really enough to bound validities by S4.2?
Fantasy Military Arms and Armor: the Dwarven Grand Armory
Why is a pressure canner needed when canning?
Is there a reason effects that introduce another combat phase also create another main phase?
What drugs were used in England during the High Middle Ages?
Would you recommend a keyboard for beginners with or without lights in keys for learning?
Is a paralyzed creature limp or rigid?
How can I oppose my advisor granting gift authorship to a collaborator?
Linux - Send Ctrl+C using linux/bash commands for specific shell script
Can any shell do argument-level interactive search?How can I remove text on the last line of a file?Getting wrong $LINENO for a trapped functionn-factor SSH authentication for CentOS 7prevent “[1] + done $scriptname” and “[1] 31303” to be shownOptional commands for bash script
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have written a shell script which processes a text input and displays the expected output, but post displaying the expected result - it waits for a ctrl+c
in order for it to complete and for cursor to move to $_ space. How can I include this ctrl+c
in my shell script itself ? or what is the shell script that does ctrl+c
using bash/shell commands ?
The script is as follows:
sed 's/xC2xA0//g' | awk '$1=="|"{if(f){print f" "$2;f=""}else{f=$2}}' filename.txt
filename.txt contains:
https://justpaste.it/edit/30310895/df1838c844c0fcd1
linux bash shell
add a comment |
I have written a shell script which processes a text input and displays the expected output, but post displaying the expected result - it waits for a ctrl+c
in order for it to complete and for cursor to move to $_ space. How can I include this ctrl+c
in my shell script itself ? or what is the shell script that does ctrl+c
using bash/shell commands ?
The script is as follows:
sed 's/xC2xA0//g' | awk '$1=="|"{if(f){print f" "$2;f=""}else{f=$2}}' filename.txt
filename.txt contains:
https://justpaste.it/edit/30310895/df1838c844c0fcd1
linux bash shell
5
Your script should just exit after the job is done. There must be something wrong with your script, you should post it here.
– David Dai
yesterday
What does the script do after it has processed the input, and how does it process the input? Please post the script in your question.
– Kusalananda♦
23 hours ago
@DavidDai updated the question
– dynamicJos
3 hours ago
@dynamicJos what do you need sed for? It doesn't do anything at all here. Just removesed 's/xC2xA0//g' |
from your script.
– David Dai
3 hours ago
add a comment |
I have written a shell script which processes a text input and displays the expected output, but post displaying the expected result - it waits for a ctrl+c
in order for it to complete and for cursor to move to $_ space. How can I include this ctrl+c
in my shell script itself ? or what is the shell script that does ctrl+c
using bash/shell commands ?
The script is as follows:
sed 's/xC2xA0//g' | awk '$1=="|"{if(f){print f" "$2;f=""}else{f=$2}}' filename.txt
filename.txt contains:
https://justpaste.it/edit/30310895/df1838c844c0fcd1
linux bash shell
I have written a shell script which processes a text input and displays the expected output, but post displaying the expected result - it waits for a ctrl+c
in order for it to complete and for cursor to move to $_ space. How can I include this ctrl+c
in my shell script itself ? or what is the shell script that does ctrl+c
using bash/shell commands ?
The script is as follows:
sed 's/xC2xA0//g' | awk '$1=="|"{if(f){print f" "$2;f=""}else{f=$2}}' filename.txt
filename.txt contains:
https://justpaste.it/edit/30310895/df1838c844c0fcd1
linux bash shell
linux bash shell
edited 44 mins ago
dynamicJos
asked yesterday
dynamicJosdynamicJos
175 bronze badges
175 bronze badges
5
Your script should just exit after the job is done. There must be something wrong with your script, you should post it here.
– David Dai
yesterday
What does the script do after it has processed the input, and how does it process the input? Please post the script in your question.
– Kusalananda♦
23 hours ago
@DavidDai updated the question
– dynamicJos
3 hours ago
@dynamicJos what do you need sed for? It doesn't do anything at all here. Just removesed 's/xC2xA0//g' |
from your script.
– David Dai
3 hours ago
add a comment |
5
Your script should just exit after the job is done. There must be something wrong with your script, you should post it here.
– David Dai
yesterday
What does the script do after it has processed the input, and how does it process the input? Please post the script in your question.
– Kusalananda♦
23 hours ago
@DavidDai updated the question
– dynamicJos
3 hours ago
@dynamicJos what do you need sed for? It doesn't do anything at all here. Just removesed 's/xC2xA0//g' |
from your script.
– David Dai
3 hours ago
5
5
Your script should just exit after the job is done. There must be something wrong with your script, you should post it here.
– David Dai
yesterday
Your script should just exit after the job is done. There must be something wrong with your script, you should post it here.
– David Dai
yesterday
What does the script do after it has processed the input, and how does it process the input? Please post the script in your question.
– Kusalananda♦
23 hours ago
What does the script do after it has processed the input, and how does it process the input? Please post the script in your question.
– Kusalananda♦
23 hours ago
@DavidDai updated the question
– dynamicJos
3 hours ago
@DavidDai updated the question
– dynamicJos
3 hours ago
@dynamicJos what do you need sed for? It doesn't do anything at all here. Just remove
sed 's/xC2xA0//g' |
from your script.– David Dai
3 hours ago
@dynamicJos what do you need sed for? It doesn't do anything at all here. Just remove
sed 's/xC2xA0//g' |
from your script.– David Dai
3 hours ago
add a comment |
2 Answers
2
active
oldest
votes
The pipeline that you show is essentially
sed expression | awk expression filename
This would run awk
on the file filename
while sed
would sit around doing nothing while waiting for input from the user on its standard input (it would read what you typed on the terminal at that point).
To exit this script, you simply press Ctrl+D to signal the end of input to the sed
process. When sed
notices that there will be nothing more to read, it terminates and the script exits (since that was what was "pausing" it).
Your current script is more or less equivalent of running
awk expression filename
sed expression
... since the two commands are not communicating with each other over the pipe.
What you want to be doing is
sed expression filename | awk expression
Here, sed
is operating on the file and sends the result over to awk
for further processing. awk
is started without a filename, which means it reads from its standard input, which is connected to the standard output of sed
via the pipe.
In your case, you want
sed 's/xC2xA0//g' filename.txt | awk '$1=="|"{if(f){print f" "$2;f=""}else{f=$2}}'
(If that pipeline does what you want it to do or not, I don't know, but now at least the sed
and awk
processes would be piped correctly).
add a comment |
ctrl-c sends the "SIGINT" signal, so to send the same effect as ^C use
kill -SIGINT
pid-of-the-script
how would I know pid of the shell that I am about to run ?
– dynamicJos
3 hours ago
if you launch it using exec it will have the same PID as the process that used exec, else you have to wait until after it is launced to find the pid
– Jasen
2 hours ago
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%2f538920%2flinux-send-ctrlc-using-linux-bash-commands-for-specific-shell-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The pipeline that you show is essentially
sed expression | awk expression filename
This would run awk
on the file filename
while sed
would sit around doing nothing while waiting for input from the user on its standard input (it would read what you typed on the terminal at that point).
To exit this script, you simply press Ctrl+D to signal the end of input to the sed
process. When sed
notices that there will be nothing more to read, it terminates and the script exits (since that was what was "pausing" it).
Your current script is more or less equivalent of running
awk expression filename
sed expression
... since the two commands are not communicating with each other over the pipe.
What you want to be doing is
sed expression filename | awk expression
Here, sed
is operating on the file and sends the result over to awk
for further processing. awk
is started without a filename, which means it reads from its standard input, which is connected to the standard output of sed
via the pipe.
In your case, you want
sed 's/xC2xA0//g' filename.txt | awk '$1=="|"{if(f){print f" "$2;f=""}else{f=$2}}'
(If that pipeline does what you want it to do or not, I don't know, but now at least the sed
and awk
processes would be piped correctly).
add a comment |
The pipeline that you show is essentially
sed expression | awk expression filename
This would run awk
on the file filename
while sed
would sit around doing nothing while waiting for input from the user on its standard input (it would read what you typed on the terminal at that point).
To exit this script, you simply press Ctrl+D to signal the end of input to the sed
process. When sed
notices that there will be nothing more to read, it terminates and the script exits (since that was what was "pausing" it).
Your current script is more or less equivalent of running
awk expression filename
sed expression
... since the two commands are not communicating with each other over the pipe.
What you want to be doing is
sed expression filename | awk expression
Here, sed
is operating on the file and sends the result over to awk
for further processing. awk
is started without a filename, which means it reads from its standard input, which is connected to the standard output of sed
via the pipe.
In your case, you want
sed 's/xC2xA0//g' filename.txt | awk '$1=="|"{if(f){print f" "$2;f=""}else{f=$2}}'
(If that pipeline does what you want it to do or not, I don't know, but now at least the sed
and awk
processes would be piped correctly).
add a comment |
The pipeline that you show is essentially
sed expression | awk expression filename
This would run awk
on the file filename
while sed
would sit around doing nothing while waiting for input from the user on its standard input (it would read what you typed on the terminal at that point).
To exit this script, you simply press Ctrl+D to signal the end of input to the sed
process. When sed
notices that there will be nothing more to read, it terminates and the script exits (since that was what was "pausing" it).
Your current script is more or less equivalent of running
awk expression filename
sed expression
... since the two commands are not communicating with each other over the pipe.
What you want to be doing is
sed expression filename | awk expression
Here, sed
is operating on the file and sends the result over to awk
for further processing. awk
is started without a filename, which means it reads from its standard input, which is connected to the standard output of sed
via the pipe.
In your case, you want
sed 's/xC2xA0//g' filename.txt | awk '$1=="|"{if(f){print f" "$2;f=""}else{f=$2}}'
(If that pipeline does what you want it to do or not, I don't know, but now at least the sed
and awk
processes would be piped correctly).
The pipeline that you show is essentially
sed expression | awk expression filename
This would run awk
on the file filename
while sed
would sit around doing nothing while waiting for input from the user on its standard input (it would read what you typed on the terminal at that point).
To exit this script, you simply press Ctrl+D to signal the end of input to the sed
process. When sed
notices that there will be nothing more to read, it terminates and the script exits (since that was what was "pausing" it).
Your current script is more or less equivalent of running
awk expression filename
sed expression
... since the two commands are not communicating with each other over the pipe.
What you want to be doing is
sed expression filename | awk expression
Here, sed
is operating on the file and sends the result over to awk
for further processing. awk
is started without a filename, which means it reads from its standard input, which is connected to the standard output of sed
via the pipe.
In your case, you want
sed 's/xC2xA0//g' filename.txt | awk '$1=="|"{if(f){print f" "$2;f=""}else{f=$2}}'
(If that pipeline does what you want it to do or not, I don't know, but now at least the sed
and awk
processes would be piped correctly).
edited 45 mins ago
answered 52 mins ago
Kusalananda♦Kusalananda
162k19 gold badges320 silver badges508 bronze badges
162k19 gold badges320 silver badges508 bronze badges
add a comment |
add a comment |
ctrl-c sends the "SIGINT" signal, so to send the same effect as ^C use
kill -SIGINT
pid-of-the-script
how would I know pid of the shell that I am about to run ?
– dynamicJos
3 hours ago
if you launch it using exec it will have the same PID as the process that used exec, else you have to wait until after it is launced to find the pid
– Jasen
2 hours ago
add a comment |
ctrl-c sends the "SIGINT" signal, so to send the same effect as ^C use
kill -SIGINT
pid-of-the-script
how would I know pid of the shell that I am about to run ?
– dynamicJos
3 hours ago
if you launch it using exec it will have the same PID as the process that used exec, else you have to wait until after it is launced to find the pid
– Jasen
2 hours ago
add a comment |
ctrl-c sends the "SIGINT" signal, so to send the same effect as ^C use
kill -SIGINT
pid-of-the-script
ctrl-c sends the "SIGINT" signal, so to send the same effect as ^C use
kill -SIGINT
pid-of-the-script
answered 21 hours ago
JasenJasen
2,6318 silver badges13 bronze badges
2,6318 silver badges13 bronze badges
how would I know pid of the shell that I am about to run ?
– dynamicJos
3 hours ago
if you launch it using exec it will have the same PID as the process that used exec, else you have to wait until after it is launced to find the pid
– Jasen
2 hours ago
add a comment |
how would I know pid of the shell that I am about to run ?
– dynamicJos
3 hours ago
if you launch it using exec it will have the same PID as the process that used exec, else you have to wait until after it is launced to find the pid
– Jasen
2 hours ago
how would I know pid of the shell that I am about to run ?
– dynamicJos
3 hours ago
how would I know pid of the shell that I am about to run ?
– dynamicJos
3 hours ago
if you launch it using exec it will have the same PID as the process that used exec, else you have to wait until after it is launced to find the pid
– Jasen
2 hours ago
if you launch it using exec it will have the same PID as the process that used exec, else you have to wait until after it is launced to find the pid
– Jasen
2 hours ago
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.
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%2f538920%2flinux-send-ctrlc-using-linux-bash-commands-for-specific-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
5
Your script should just exit after the job is done. There must be something wrong with your script, you should post it here.
– David Dai
yesterday
What does the script do after it has processed the input, and how does it process the input? Please post the script in your question.
– Kusalananda♦
23 hours ago
@DavidDai updated the question
– dynamicJos
3 hours ago
@dynamicJos what do you need sed for? It doesn't do anything at all here. Just remove
sed 's/xC2xA0//g' |
from your script.– David Dai
3 hours ago