Unknowingly ran an infinite loop in terminalDifference between the terminal file and the terminal screenWhy does reading from two connected pty's cause an infinite loop?Pushdown Terminal OutputCan the empty spaces/background in a terminal be replaced with a random(but pretty) pattern of ASCII characters?Posix command that moves cursor to specific position in terminal windowHow to disable vcstimeCannot terminate for loop in terminalTerminal vs Terminal emulatorTerminal: remember working directoryStopping infinit loop from php script run in linux terminal

Handling Null values (and equivalents) routinely in Python

Has the United States ever had a non-Christian President?

Has a commercial or military jet bi-plane ever been manufactured?

Can you use "едать" and "игрывать" in the present and future tenses?

If all diagonals are drawn in a regular polygon from a vertex, the angles formed in that vertex are equal

Find magical solution to magical equation

Can there be a single technologically advanced nation, in a continent full of non-technologically advanced nations?

Checking if two expressions are related

How do I calculate how many of an item I'll have in this inventory system?

It is as simple as ABC

What do "Sech" and "Vich" mean in this sentence?

Can I use a Cat5e cable with an RJ45 and Cat6 port?

Notation: What does the tilde below of the expectation mean?

SOQL query WHERE filter by specific months

Why is my arithmetic with a long long int behaving this way?

Endgame puzzle: How to avoid stalemate and win?

Would a small hole in a Faraday cage drastically reduce its effectiveness at blocking interference?

What to use instead of cling film to wrap pastry

Mug and wireframe entirely disappeared

What do I do if my advisor made a mistake?

Nested loops to process groups of pictures

Is the book wrong about the Nyquist Sampling Criterion?

Dihedral group D4 composition with custom labels

How can I get people to remember my character's gender?



Unknowingly ran an infinite loop in terminal


Difference between the terminal file and the terminal screenWhy does reading from two connected pty's cause an infinite loop?Pushdown Terminal OutputCan the empty spaces/background in a terminal be replaced with a random(but pretty) pattern of ASCII characters?Posix command that moves cursor to specific position in terminal windowHow to disable vcstimeCannot terminate for loop in terminalTerminal vs Terminal emulatorTerminal: remember working directoryStopping infinit loop from php script run in linux terminal






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








9















I copied the below code from some random source to my terminal and ran:



while sleep 1;
do tput sc;
tput cup 0 $(($(tput cols)-29));
date;
tput rc;
done &


The code is to show a running clock at the top right corner of the terminal. The snippet worked very well and exactly did what I wanted it to, but now I just want to end this loop and get rid of the clock.



Also, I need to understand the above code. I've some idea, as I know what tput command does, but still there're many dots which I'm not able to connect.










share|improve this question



















  • 1





    You can run jobs in your session to list active background jobs and then put it to foreground by typing fg <job number>. After type Ctrl+C to stop this infinite loop. This scenario is working only in terminal that run snippet.

    – Yurij Goncharuk
    Apr 30 at 20:48












  • Thank you very much, a very clean way of getting rid of the loop. This should become the accepted answer.

    – Kartik Chauhan
    Apr 30 at 20:54











  • You are welcome! I put it as answer bellow.

    – Yurij Goncharuk
    Apr 30 at 20:56






  • 1





    Note that simply closing the terminal window will also terminate all running jobs attached to it.

    – trlkly
    Apr 30 at 21:32












  • You have two questions here. Can you split the 2nd, to a new question.

    – ctrl-alt-delor
    Apr 30 at 21:43

















9















I copied the below code from some random source to my terminal and ran:



while sleep 1;
do tput sc;
tput cup 0 $(($(tput cols)-29));
date;
tput rc;
done &


The code is to show a running clock at the top right corner of the terminal. The snippet worked very well and exactly did what I wanted it to, but now I just want to end this loop and get rid of the clock.



Also, I need to understand the above code. I've some idea, as I know what tput command does, but still there're many dots which I'm not able to connect.










share|improve this question



















  • 1





    You can run jobs in your session to list active background jobs and then put it to foreground by typing fg <job number>. After type Ctrl+C to stop this infinite loop. This scenario is working only in terminal that run snippet.

    – Yurij Goncharuk
    Apr 30 at 20:48












  • Thank you very much, a very clean way of getting rid of the loop. This should become the accepted answer.

    – Kartik Chauhan
    Apr 30 at 20:54











  • You are welcome! I put it as answer bellow.

    – Yurij Goncharuk
    Apr 30 at 20:56






  • 1





    Note that simply closing the terminal window will also terminate all running jobs attached to it.

    – trlkly
    Apr 30 at 21:32












  • You have two questions here. Can you split the 2nd, to a new question.

    – ctrl-alt-delor
    Apr 30 at 21:43













9












9








9


3






I copied the below code from some random source to my terminal and ran:



while sleep 1;
do tput sc;
tput cup 0 $(($(tput cols)-29));
date;
tput rc;
done &


The code is to show a running clock at the top right corner of the terminal. The snippet worked very well and exactly did what I wanted it to, but now I just want to end this loop and get rid of the clock.



Also, I need to understand the above code. I've some idea, as I know what tput command does, but still there're many dots which I'm not able to connect.










share|improve this question
















I copied the below code from some random source to my terminal and ran:



while sleep 1;
do tput sc;
tput cup 0 $(($(tput cols)-29));
date;
tput rc;
done &


The code is to show a running clock at the top right corner of the terminal. The snippet worked very well and exactly did what I wanted it to, but now I just want to end this loop and get rid of the clock.



Also, I need to understand the above code. I've some idea, as I know what tput command does, but still there're many dots which I'm not able to connect.







terminal






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Rui F Ribeiro

42.6k1486146




42.6k1486146










asked Apr 30 at 20:42









Kartik ChauhanKartik Chauhan

1565




1565







  • 1





    You can run jobs in your session to list active background jobs and then put it to foreground by typing fg <job number>. After type Ctrl+C to stop this infinite loop. This scenario is working only in terminal that run snippet.

    – Yurij Goncharuk
    Apr 30 at 20:48












  • Thank you very much, a very clean way of getting rid of the loop. This should become the accepted answer.

    – Kartik Chauhan
    Apr 30 at 20:54











  • You are welcome! I put it as answer bellow.

    – Yurij Goncharuk
    Apr 30 at 20:56






  • 1





    Note that simply closing the terminal window will also terminate all running jobs attached to it.

    – trlkly
    Apr 30 at 21:32












  • You have two questions here. Can you split the 2nd, to a new question.

    – ctrl-alt-delor
    Apr 30 at 21:43












  • 1





    You can run jobs in your session to list active background jobs and then put it to foreground by typing fg <job number>. After type Ctrl+C to stop this infinite loop. This scenario is working only in terminal that run snippet.

    – Yurij Goncharuk
    Apr 30 at 20:48












  • Thank you very much, a very clean way of getting rid of the loop. This should become the accepted answer.

    – Kartik Chauhan
    Apr 30 at 20:54











  • You are welcome! I put it as answer bellow.

    – Yurij Goncharuk
    Apr 30 at 20:56






  • 1





    Note that simply closing the terminal window will also terminate all running jobs attached to it.

    – trlkly
    Apr 30 at 21:32












  • You have two questions here. Can you split the 2nd, to a new question.

    – ctrl-alt-delor
    Apr 30 at 21:43







1




1





You can run jobs in your session to list active background jobs and then put it to foreground by typing fg <job number>. After type Ctrl+C to stop this infinite loop. This scenario is working only in terminal that run snippet.

– Yurij Goncharuk
Apr 30 at 20:48






You can run jobs in your session to list active background jobs and then put it to foreground by typing fg <job number>. After type Ctrl+C to stop this infinite loop. This scenario is working only in terminal that run snippet.

– Yurij Goncharuk
Apr 30 at 20:48














Thank you very much, a very clean way of getting rid of the loop. This should become the accepted answer.

– Kartik Chauhan
Apr 30 at 20:54





Thank you very much, a very clean way of getting rid of the loop. This should become the accepted answer.

– Kartik Chauhan
Apr 30 at 20:54













You are welcome! I put it as answer bellow.

– Yurij Goncharuk
Apr 30 at 20:56





You are welcome! I put it as answer bellow.

– Yurij Goncharuk
Apr 30 at 20:56




1




1





Note that simply closing the terminal window will also terminate all running jobs attached to it.

– trlkly
Apr 30 at 21:32






Note that simply closing the terminal window will also terminate all running jobs attached to it.

– trlkly
Apr 30 at 21:32














You have two questions here. Can you split the 2nd, to a new question.

– ctrl-alt-delor
Apr 30 at 21:43





You have two questions here. Can you split the 2nd, to a new question.

– ctrl-alt-delor
Apr 30 at 21:43










1 Answer
1






active

oldest

votes


















15














You can run jobs command in your session to list active background jobs and then put them to foreground by typing fg <job number>. Then type Ctrl+C to stop this infinite loop.



This scenario is working only in terminal that run snippet.




Explanation:



tput sc - save cursor position.



tput cup 0 $(($(tput cols)-29)) - move cursor to position 0 of Y axis and (count of screen columns minus 29) of X axis.



date - just print current date.



tput rc - restore cursor position.



while sleep 1; ... do ... ; done - loop with delay of 1 second.



Type help while to know more about while loop in shell and follow to man 1 tput or tldp tput doc to know how tput works.






share|improve this answer

























  • I still would like to know how did the code do what it did.

    – Kartik Chauhan
    Apr 30 at 20:58











  • @KartikChauhan I put some explanation also.

    – Yurij Goncharuk
    Apr 30 at 21:14











  • @KartikChauhan You are right! Thank's! I've just fixed this.

    – Yurij Goncharuk
    Apr 30 at 21:20







  • 3





    kill %1 (or a different number if there are multiple jobs) is an alternative to fg + Ctrl-C

    – Roman Odaisky
    Apr 30 at 23:18











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%2f516453%2funknowingly-ran-an-infinite-loop-in-terminal%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









15














You can run jobs command in your session to list active background jobs and then put them to foreground by typing fg <job number>. Then type Ctrl+C to stop this infinite loop.



This scenario is working only in terminal that run snippet.




Explanation:



tput sc - save cursor position.



tput cup 0 $(($(tput cols)-29)) - move cursor to position 0 of Y axis and (count of screen columns minus 29) of X axis.



date - just print current date.



tput rc - restore cursor position.



while sleep 1; ... do ... ; done - loop with delay of 1 second.



Type help while to know more about while loop in shell and follow to man 1 tput or tldp tput doc to know how tput works.






share|improve this answer

























  • I still would like to know how did the code do what it did.

    – Kartik Chauhan
    Apr 30 at 20:58











  • @KartikChauhan I put some explanation also.

    – Yurij Goncharuk
    Apr 30 at 21:14











  • @KartikChauhan You are right! Thank's! I've just fixed this.

    – Yurij Goncharuk
    Apr 30 at 21:20







  • 3





    kill %1 (or a different number if there are multiple jobs) is an alternative to fg + Ctrl-C

    – Roman Odaisky
    Apr 30 at 23:18















15














You can run jobs command in your session to list active background jobs and then put them to foreground by typing fg <job number>. Then type Ctrl+C to stop this infinite loop.



This scenario is working only in terminal that run snippet.




Explanation:



tput sc - save cursor position.



tput cup 0 $(($(tput cols)-29)) - move cursor to position 0 of Y axis and (count of screen columns minus 29) of X axis.



date - just print current date.



tput rc - restore cursor position.



while sleep 1; ... do ... ; done - loop with delay of 1 second.



Type help while to know more about while loop in shell and follow to man 1 tput or tldp tput doc to know how tput works.






share|improve this answer

























  • I still would like to know how did the code do what it did.

    – Kartik Chauhan
    Apr 30 at 20:58











  • @KartikChauhan I put some explanation also.

    – Yurij Goncharuk
    Apr 30 at 21:14











  • @KartikChauhan You are right! Thank's! I've just fixed this.

    – Yurij Goncharuk
    Apr 30 at 21:20







  • 3





    kill %1 (or a different number if there are multiple jobs) is an alternative to fg + Ctrl-C

    – Roman Odaisky
    Apr 30 at 23:18













15












15








15







You can run jobs command in your session to list active background jobs and then put them to foreground by typing fg <job number>. Then type Ctrl+C to stop this infinite loop.



This scenario is working only in terminal that run snippet.




Explanation:



tput sc - save cursor position.



tput cup 0 $(($(tput cols)-29)) - move cursor to position 0 of Y axis and (count of screen columns minus 29) of X axis.



date - just print current date.



tput rc - restore cursor position.



while sleep 1; ... do ... ; done - loop with delay of 1 second.



Type help while to know more about while loop in shell and follow to man 1 tput or tldp tput doc to know how tput works.






share|improve this answer















You can run jobs command in your session to list active background jobs and then put them to foreground by typing fg <job number>. Then type Ctrl+C to stop this infinite loop.



This scenario is working only in terminal that run snippet.




Explanation:



tput sc - save cursor position.



tput cup 0 $(($(tput cols)-29)) - move cursor to position 0 of Y axis and (count of screen columns minus 29) of X axis.



date - just print current date.



tput rc - restore cursor position.



while sleep 1; ... do ... ; done - loop with delay of 1 second.



Type help while to know more about while loop in shell and follow to man 1 tput or tldp tput doc to know how tput works.







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 30 at 21:42









ctrl-alt-delor

12.8k52663




12.8k52663










answered Apr 30 at 20:56









Yurij GoncharukYurij Goncharuk

2,5992825




2,5992825












  • I still would like to know how did the code do what it did.

    – Kartik Chauhan
    Apr 30 at 20:58











  • @KartikChauhan I put some explanation also.

    – Yurij Goncharuk
    Apr 30 at 21:14











  • @KartikChauhan You are right! Thank's! I've just fixed this.

    – Yurij Goncharuk
    Apr 30 at 21:20







  • 3





    kill %1 (or a different number if there are multiple jobs) is an alternative to fg + Ctrl-C

    – Roman Odaisky
    Apr 30 at 23:18

















  • I still would like to know how did the code do what it did.

    – Kartik Chauhan
    Apr 30 at 20:58











  • @KartikChauhan I put some explanation also.

    – Yurij Goncharuk
    Apr 30 at 21:14











  • @KartikChauhan You are right! Thank's! I've just fixed this.

    – Yurij Goncharuk
    Apr 30 at 21:20







  • 3





    kill %1 (or a different number if there are multiple jobs) is an alternative to fg + Ctrl-C

    – Roman Odaisky
    Apr 30 at 23:18
















I still would like to know how did the code do what it did.

– Kartik Chauhan
Apr 30 at 20:58





I still would like to know how did the code do what it did.

– Kartik Chauhan
Apr 30 at 20:58













@KartikChauhan I put some explanation also.

– Yurij Goncharuk
Apr 30 at 21:14





@KartikChauhan I put some explanation also.

– Yurij Goncharuk
Apr 30 at 21:14













@KartikChauhan You are right! Thank's! I've just fixed this.

– Yurij Goncharuk
Apr 30 at 21:20






@KartikChauhan You are right! Thank's! I've just fixed this.

– Yurij Goncharuk
Apr 30 at 21:20





3




3





kill %1 (or a different number if there are multiple jobs) is an alternative to fg + Ctrl-C

– Roman Odaisky
Apr 30 at 23:18





kill %1 (or a different number if there are multiple jobs) is an alternative to fg + Ctrl-C

– Roman Odaisky
Apr 30 at 23:18

















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%2f516453%2funknowingly-ran-an-infinite-loop-in-terminal%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

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form