Bash Script read -pProblem with script substitution when running scriptError message 'source: not found' when running a script.sh file on Startup Applications isn't executedProblem with input from simple script that copies a file to a different directorybash script to run a second command with select output from first command as variableWant to write a bash script to automate creating program filesRead input for bash scriptexit a bash command in a script without exiting the scriptProper method for storing user input in bash scriptsHow to pass a value to read input before being prompted?

Global BGP Routing only by only importing supernet prefixes

Creating some gif with tikz: Any idea to get better result?

Do you "gain" 1st level?

Boss wants me to ignore a software API license

Xdebug not working over Drush

Installing Windows to flash UEFI/ BIOS, then reinstalling Ubuntu

Running code generated in realtime in JavaScript with eval()

What kind of liquid can be seen 'leaking' from the upper surface of the wing of a Boeing 737-800?

Are there any other rule mechanics that could grant Thieves' Cant?

When was "Fredo" an insult to Italian-Americans?

Doesn't the speed of light limit imply the same electron can be annihilated twice?

Did Pope Urban II issue the papal bull "terra nullius" in 1095?

What is a "soap"?

Would the USA be eligible to join the European Union?

Locked Room Murder!! How and who?

Why aren’t there water shutoff valves for each room?

A trip to the library

How does the Athlete Feat affect the Ravnica Centaur playable race?

Did DOS zero out the BSS area when it loaded a program?

(A room / an office) where an artist works

What is the hottest thing in the universe?

How far did Gandalf and the Balrog drop from the bridge in Moria?

Are there really no countries that protect Freedom of Speech as the United States does?

Weird resistor with dots around it



Bash Script read -p


Problem with script substitution when running scriptError message 'source: not found' when running a script.sh file on Startup Applications isn't executedProblem with input from simple script that copies a file to a different directorybash script to run a second command with select output from first command as variableWant to write a bash script to automate creating program filesRead input for bash scriptexit a bash command in a script without exiting the scriptProper method for storing user input in bash scriptsHow to pass a value to read input before being prompted?






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








3















I'm pretty sure the answer is no but I thought I'd ask anyway. I want to have a bash script with a user input that automatically proceeds after the desired amount of characters are entered, in this case 3.



So when the user enters 123 or abc, the script moves on with that variable rather than waiting for an 'Enter'.



read -p 'User Input: ' userInput


Is this possible?










share|improve this question
































    3















    I'm pretty sure the answer is no but I thought I'd ask anyway. I want to have a bash script with a user input that automatically proceeds after the desired amount of characters are entered, in this case 3.



    So when the user enters 123 or abc, the script moves on with that variable rather than waiting for an 'Enter'.



    read -p 'User Input: ' userInput


    Is this possible?










    share|improve this question




























      3












      3








      3








      I'm pretty sure the answer is no but I thought I'd ask anyway. I want to have a bash script with a user input that automatically proceeds after the desired amount of characters are entered, in this case 3.



      So when the user enters 123 or abc, the script moves on with that variable rather than waiting for an 'Enter'.



      read -p 'User Input: ' userInput


      Is this possible?










      share|improve this question
















      I'm pretty sure the answer is no but I thought I'd ask anyway. I want to have a bash script with a user input that automatically proceeds after the desired amount of characters are entered, in this case 3.



      So when the user enters 123 or abc, the script moves on with that variable rather than waiting for an 'Enter'.



      read -p 'User Input: ' userInput


      Is this possible?







      bash scripts






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 2 at 17:09









      terdon

      72.9k14 gold badges149 silver badges233 bronze badges




      72.9k14 gold badges149 silver badges233 bronze badges










      asked Aug 2 at 16:01









      Ashton WattsAshton Watts

      252 bronze badges




      252 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          5














          In bash, you can add -n 3 or -N 3 depending on the exact behavior you require. From help read:




           -n nchars return after reading NCHARS characters rather than waiting
          for a newline, but honor a delimiter if fewer than
          NCHARS characters are read before the delimiter
          -N nchars return only after reading exactly NCHARS characters, unless
          EOF is encountered or read times out, ignoring any
          delimiter






          share|improve this answer

























          • If I try adding -N 3 or -n 3 it says illegal option -n.

            – Ashton Watts
            Aug 2 at 18:25






          • 1





            @AshtonWatts are you sure you are using bash - not sh (or dash)?

            – steeldriver
            Aug 2 at 18:35











          • Yeah the problem was that I wasn't running it as bash. Working fine now.

            – Ashton Watts
            Aug 2 at 19:27













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



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1162955%2fbash-script-read-p%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









          5














          In bash, you can add -n 3 or -N 3 depending on the exact behavior you require. From help read:




           -n nchars return after reading NCHARS characters rather than waiting
          for a newline, but honor a delimiter if fewer than
          NCHARS characters are read before the delimiter
          -N nchars return only after reading exactly NCHARS characters, unless
          EOF is encountered or read times out, ignoring any
          delimiter






          share|improve this answer

























          • If I try adding -N 3 or -n 3 it says illegal option -n.

            – Ashton Watts
            Aug 2 at 18:25






          • 1





            @AshtonWatts are you sure you are using bash - not sh (or dash)?

            – steeldriver
            Aug 2 at 18:35











          • Yeah the problem was that I wasn't running it as bash. Working fine now.

            – Ashton Watts
            Aug 2 at 19:27















          5














          In bash, you can add -n 3 or -N 3 depending on the exact behavior you require. From help read:




           -n nchars return after reading NCHARS characters rather than waiting
          for a newline, but honor a delimiter if fewer than
          NCHARS characters are read before the delimiter
          -N nchars return only after reading exactly NCHARS characters, unless
          EOF is encountered or read times out, ignoring any
          delimiter






          share|improve this answer

























          • If I try adding -N 3 or -n 3 it says illegal option -n.

            – Ashton Watts
            Aug 2 at 18:25






          • 1





            @AshtonWatts are you sure you are using bash - not sh (or dash)?

            – steeldriver
            Aug 2 at 18:35











          • Yeah the problem was that I wasn't running it as bash. Working fine now.

            – Ashton Watts
            Aug 2 at 19:27













          5












          5








          5







          In bash, you can add -n 3 or -N 3 depending on the exact behavior you require. From help read:




           -n nchars return after reading NCHARS characters rather than waiting
          for a newline, but honor a delimiter if fewer than
          NCHARS characters are read before the delimiter
          -N nchars return only after reading exactly NCHARS characters, unless
          EOF is encountered or read times out, ignoring any
          delimiter






          share|improve this answer













          In bash, you can add -n 3 or -N 3 depending on the exact behavior you require. From help read:




           -n nchars return after reading NCHARS characters rather than waiting
          for a newline, but honor a delimiter if fewer than
          NCHARS characters are read before the delimiter
          -N nchars return only after reading exactly NCHARS characters, unless
          EOF is encountered or read times out, ignoring any
          delimiter







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 2 at 16:05









          steeldriversteeldriver

          77.7k12 gold badges129 silver badges207 bronze badges




          77.7k12 gold badges129 silver badges207 bronze badges















          • If I try adding -N 3 or -n 3 it says illegal option -n.

            – Ashton Watts
            Aug 2 at 18:25






          • 1





            @AshtonWatts are you sure you are using bash - not sh (or dash)?

            – steeldriver
            Aug 2 at 18:35











          • Yeah the problem was that I wasn't running it as bash. Working fine now.

            – Ashton Watts
            Aug 2 at 19:27

















          • If I try adding -N 3 or -n 3 it says illegal option -n.

            – Ashton Watts
            Aug 2 at 18:25






          • 1





            @AshtonWatts are you sure you are using bash - not sh (or dash)?

            – steeldriver
            Aug 2 at 18:35











          • Yeah the problem was that I wasn't running it as bash. Working fine now.

            – Ashton Watts
            Aug 2 at 19:27
















          If I try adding -N 3 or -n 3 it says illegal option -n.

          – Ashton Watts
          Aug 2 at 18:25





          If I try adding -N 3 or -n 3 it says illegal option -n.

          – Ashton Watts
          Aug 2 at 18:25




          1




          1





          @AshtonWatts are you sure you are using bash - not sh (or dash)?

          – steeldriver
          Aug 2 at 18:35





          @AshtonWatts are you sure you are using bash - not sh (or dash)?

          – steeldriver
          Aug 2 at 18:35













          Yeah the problem was that I wasn't running it as bash. Working fine now.

          – Ashton Watts
          Aug 2 at 19:27





          Yeah the problem was that I wasn't running it as bash. Working fine now.

          – Ashton Watts
          Aug 2 at 19:27

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1162955%2fbash-script-read-p%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

          Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

          Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

          Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림