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;
}







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










share|improve this question






















  • 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




















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










share|improve this question






















  • 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
















0












0








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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 remove sed 's/xC2xA0//g' | from your script.

    – David Dai
    3 hours ago
















  • 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










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












2 Answers
2






active

oldest

votes


















1
















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).






share|improve this answer



































    1
















    ctrl-c sends the "SIGINT" signal, so to send the same effect as ^C use



    kill -SIGINT pid-of-the-script






    share|improve this answer


























    • 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














    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    1
















    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).






    share|improve this answer
































      1
















      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).






      share|improve this answer






























        1














        1










        1









        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).






        share|improve this answer















        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).







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 45 mins ago

























        answered 52 mins ago









        KusalanandaKusalananda

        162k19 gold badges320 silver badges508 bronze badges




        162k19 gold badges320 silver badges508 bronze badges




























            1
















            ctrl-c sends the "SIGINT" signal, so to send the same effect as ^C use



            kill -SIGINT pid-of-the-script






            share|improve this answer


























            • 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
















            1
















            ctrl-c sends the "SIGINT" signal, so to send the same effect as ^C use



            kill -SIGINT pid-of-the-script






            share|improve this answer


























            • 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














            1














            1










            1









            ctrl-c sends the "SIGINT" signal, so to send the same effect as ^C use



            kill -SIGINT pid-of-the-script






            share|improve this answer













            ctrl-c sends the "SIGINT" signal, so to send the same effect as ^C use



            kill -SIGINT pid-of-the-script







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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



















            • 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


















            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...