Variable completely messes up echoed string2019 Community Moderator ElectionAppend variable string to itselfTake output field data string into variableBash perform variable expansion of stringCombining a variable value and string to form another variableprintf escape %q string vs variablecompare variable with string bashPrinting variable value prints string Shell scriptingDo not expand string inside variablePrepare arguments containing quoted string in variableSSH terminal messes multiline commands

Probably overheated black color SMD pads

Describing a chess game in a novel

Do ranged attacks with improvised weapons get the bonus from the archery fighting style?

While on vacation my taxi took a longer route, possibly to scam me out of money. How can I deal with this?

Constant Current LED Circuit

Could this Scherzo by Beethoven be considered to be a fugue?

Why is a polar cone a closed set?

Deletion of copy-ctor & copy-assignment - public, private or protected?

How does one measure the Fourier components of a signal?

PTIJ What is the inyan of the Konami code in Uncle Moishy's song?

Using Leaflet inside Bootstrap container?

How to get the n-th line after a grepped one?

The average age of first marriage in Russia

Does multi-classing into Fighter give you heavy armor proficiency?

Is there a term for accumulated dirt on the outside of your hands and feet?

How are passwords stolen from companies if they only store hashes?

usage and meaning of Up

How can I wire 7 outdoor posts correctly?

Recruiter wants very extensive technical details about all of my previous work

How could an airship be repaired midflight?

Why is there so much iron?

Is it correct to say "which country do you like the most?"

What favor did Moody owe Dumbledore?

What is the plural TO OF sth



Variable completely messes up echoed string



2019 Community Moderator ElectionAppend variable string to itselfTake output field data string into variableBash perform variable expansion of stringCombining a variable value and string to form another variableprintf escape %q string vs variablecompare variable with string bashPrinting variable value prints string Shell scriptingDo not expand string inside variablePrepare arguments containing quoted string in variableSSH terminal messes multiline commands










1















So I really have no idea how to better describe this than the title.



So I discovered this website called pwnedpasswords, where you can apparently check to see if your password's sha1 hash has been leaked somewhere. So I made a script to automate the process, here's my script:



#!/bin/bash

read -s -p "Input your password: " your_pw
echo
your_hash=$(printf "$your_pw"|sha1sum|tr '[:lower:]' '[:upper:]'|head -c40)
hash_head=$(printf "$your_hash"|head -c5)
hash_tail=$(printf "$your_hash"|tail -c35)

pwned_count=$(curl https://api.pwnedpasswords.com/range/$hash_head 2> /dev/null|grep "$hash_tail"|awk -F ':' 'print $2')
echo "Your password has been pwned $your_pw times"
echo "Your password has been pwned $pwned_count times"


And I used as a test password 1, and this is the output:



[me@my_compuuter aaa8]$ ./was_your_password_pwned.sh
Input your password:
Your password has been pwned 1 times
timesassword has been pwned 197972


Notice how when I echo "Your password has been pwned $your_pw times"
it gives me the correct format ($your_pw is just the password itself), but when I echo "Your password has been pwned $pwned_count times" it gives me this weird format where it takes the times from the end and somehow overlaps it in the beginning... I have no clue what's going on...



Can somebody figure it out?










share|improve this question


























    1















    So I really have no idea how to better describe this than the title.



    So I discovered this website called pwnedpasswords, where you can apparently check to see if your password's sha1 hash has been leaked somewhere. So I made a script to automate the process, here's my script:



    #!/bin/bash

    read -s -p "Input your password: " your_pw
    echo
    your_hash=$(printf "$your_pw"|sha1sum|tr '[:lower:]' '[:upper:]'|head -c40)
    hash_head=$(printf "$your_hash"|head -c5)
    hash_tail=$(printf "$your_hash"|tail -c35)

    pwned_count=$(curl https://api.pwnedpasswords.com/range/$hash_head 2> /dev/null|grep "$hash_tail"|awk -F ':' 'print $2')
    echo "Your password has been pwned $your_pw times"
    echo "Your password has been pwned $pwned_count times"


    And I used as a test password 1, and this is the output:



    [me@my_compuuter aaa8]$ ./was_your_password_pwned.sh
    Input your password:
    Your password has been pwned 1 times
    timesassword has been pwned 197972


    Notice how when I echo "Your password has been pwned $your_pw times"
    it gives me the correct format ($your_pw is just the password itself), but when I echo "Your password has been pwned $pwned_count times" it gives me this weird format where it takes the times from the end and somehow overlaps it in the beginning... I have no clue what's going on...



    Can somebody figure it out?










    share|improve this question
























      1












      1








      1








      So I really have no idea how to better describe this than the title.



      So I discovered this website called pwnedpasswords, where you can apparently check to see if your password's sha1 hash has been leaked somewhere. So I made a script to automate the process, here's my script:



      #!/bin/bash

      read -s -p "Input your password: " your_pw
      echo
      your_hash=$(printf "$your_pw"|sha1sum|tr '[:lower:]' '[:upper:]'|head -c40)
      hash_head=$(printf "$your_hash"|head -c5)
      hash_tail=$(printf "$your_hash"|tail -c35)

      pwned_count=$(curl https://api.pwnedpasswords.com/range/$hash_head 2> /dev/null|grep "$hash_tail"|awk -F ':' 'print $2')
      echo "Your password has been pwned $your_pw times"
      echo "Your password has been pwned $pwned_count times"


      And I used as a test password 1, and this is the output:



      [me@my_compuuter aaa8]$ ./was_your_password_pwned.sh
      Input your password:
      Your password has been pwned 1 times
      timesassword has been pwned 197972


      Notice how when I echo "Your password has been pwned $your_pw times"
      it gives me the correct format ($your_pw is just the password itself), but when I echo "Your password has been pwned $pwned_count times" it gives me this weird format where it takes the times from the end and somehow overlaps it in the beginning... I have no clue what's going on...



      Can somebody figure it out?










      share|improve this question














      So I really have no idea how to better describe this than the title.



      So I discovered this website called pwnedpasswords, where you can apparently check to see if your password's sha1 hash has been leaked somewhere. So I made a script to automate the process, here's my script:



      #!/bin/bash

      read -s -p "Input your password: " your_pw
      echo
      your_hash=$(printf "$your_pw"|sha1sum|tr '[:lower:]' '[:upper:]'|head -c40)
      hash_head=$(printf "$your_hash"|head -c5)
      hash_tail=$(printf "$your_hash"|tail -c35)

      pwned_count=$(curl https://api.pwnedpasswords.com/range/$hash_head 2> /dev/null|grep "$hash_tail"|awk -F ':' 'print $2')
      echo "Your password has been pwned $your_pw times"
      echo "Your password has been pwned $pwned_count times"


      And I used as a test password 1, and this is the output:



      [me@my_compuuter aaa8]$ ./was_your_password_pwned.sh
      Input your password:
      Your password has been pwned 1 times
      timesassword has been pwned 197972


      Notice how when I echo "Your password has been pwned $your_pw times"
      it gives me the correct format ($your_pw is just the password itself), but when I echo "Your password has been pwned $pwned_count times" it gives me this weird format where it takes the times from the end and somehow overlaps it in the beginning... I have no clue what's going on...



      Can somebody figure it out?







      bash






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 55 mins ago









      user323587user323587

      222




      222




















          1 Answer
          1






          active

          oldest

          votes


















          3














          The list returned by that site has lines terminated by CR/LF. A CR (r) will move the caret/cursor to the beginning of the line:



          printf 'good r times'
          times





          share|improve this answer























          • Wow thanks! I just added |tr 'r' 'n' to the end of the pwned_count variable and now it works properly, thanks!

            – user323587
            40 mins ago











          • @user323587, tr -d 'r' would be more common, it actually removes the carriage return. Changing it to a newline of course works in your case, too, since the command substitution removes all trailing newlines.

            – ilkkachu
            31 mins 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%2f506865%2fvariable-completely-messes-up-echoed-string%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









          3














          The list returned by that site has lines terminated by CR/LF. A CR (r) will move the caret/cursor to the beginning of the line:



          printf 'good r times'
          times





          share|improve this answer























          • Wow thanks! I just added |tr 'r' 'n' to the end of the pwned_count variable and now it works properly, thanks!

            – user323587
            40 mins ago











          • @user323587, tr -d 'r' would be more common, it actually removes the carriage return. Changing it to a newline of course works in your case, too, since the command substitution removes all trailing newlines.

            – ilkkachu
            31 mins ago















          3














          The list returned by that site has lines terminated by CR/LF. A CR (r) will move the caret/cursor to the beginning of the line:



          printf 'good r times'
          times





          share|improve this answer























          • Wow thanks! I just added |tr 'r' 'n' to the end of the pwned_count variable and now it works properly, thanks!

            – user323587
            40 mins ago











          • @user323587, tr -d 'r' would be more common, it actually removes the carriage return. Changing it to a newline of course works in your case, too, since the command substitution removes all trailing newlines.

            – ilkkachu
            31 mins ago













          3












          3








          3







          The list returned by that site has lines terminated by CR/LF. A CR (r) will move the caret/cursor to the beginning of the line:



          printf 'good r times'
          times





          share|improve this answer













          The list returned by that site has lines terminated by CR/LF. A CR (r) will move the caret/cursor to the beginning of the line:



          printf 'good r times'
          times






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 42 mins ago









          Uncle BillyUncle Billy

          6907




          6907












          • Wow thanks! I just added |tr 'r' 'n' to the end of the pwned_count variable and now it works properly, thanks!

            – user323587
            40 mins ago











          • @user323587, tr -d 'r' would be more common, it actually removes the carriage return. Changing it to a newline of course works in your case, too, since the command substitution removes all trailing newlines.

            – ilkkachu
            31 mins ago

















          • Wow thanks! I just added |tr 'r' 'n' to the end of the pwned_count variable and now it works properly, thanks!

            – user323587
            40 mins ago











          • @user323587, tr -d 'r' would be more common, it actually removes the carriage return. Changing it to a newline of course works in your case, too, since the command substitution removes all trailing newlines.

            – ilkkachu
            31 mins ago
















          Wow thanks! I just added |tr 'r' 'n' to the end of the pwned_count variable and now it works properly, thanks!

          – user323587
          40 mins ago





          Wow thanks! I just added |tr 'r' 'n' to the end of the pwned_count variable and now it works properly, thanks!

          – user323587
          40 mins ago













          @user323587, tr -d 'r' would be more common, it actually removes the carriage return. Changing it to a newline of course works in your case, too, since the command substitution removes all trailing newlines.

          – ilkkachu
          31 mins ago





          @user323587, tr -d 'r' would be more common, it actually removes the carriage return. Changing it to a newline of course works in your case, too, since the command substitution removes all trailing newlines.

          – ilkkachu
          31 mins 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%2f506865%2fvariable-completely-messes-up-echoed-string%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

          瀋陽號驅逐艦 目录 接收與服役 配置反潛直升機 武進三型性能升級 歷史 除役 參考資料 外部連結 导航菜单Taiwan Air Power海疆老兵-陽字號驅逐艦沿革World Navies Today: Taiwan (Republic of China)DD-839 USS POWER

          波兰旗帜列表 目录 国旗 军旗 其他制服部门旗帜 特别国家机构船只 参考文献 外部链接 导航菜单Polskie flagi, chorągwie, bandery... [波兰旗帜、条幅、船旗等]原始内容Ustawa z dnia 31 stycznia 1980 r. o godle, barwach i hymnie Rzeczypospolitej Polskiej oraz o pieczęciach państwowychZarządzenie Ministra Obrony Narodowej z dnia 14 grudnia 2005 r. zmieniające zarządzenie w sprawie szczegółowych zasad używania znaków Sił Zbrojnych Rzeczypospolitej Polskiej oraz ustalenia innych znaków używanych w Siłach Zbrojnych Rzeczypospolitej PolskiejZarządzenie Ministra Obrony Narodowej z dnia 29 stycznia 1996 r. w sprawie szczegółowych zasad używania znaków Sił Zbrojnych Rzeczypospolitej Polskiej oraz ustalenia innych znaków używanych w Siłach Zbrojnych Rzeczypospolitej PolskiejUstawa z dnia 19 lutego 1993 r. o znakach Sił Zbrojnych Rzeczypospolitej PolskiejHistoria Marynarki Wojennej RP [波兰海军史]Rozporządzenie Ministra Spraw Wewnętrznych i Administracji z dnia 12 kwietnia 2002 r. w sprawie wzoru flagi oraz oznakowania jednostek pływających i statków powietrznych Straży GranicznejRozporządzenie Ministra Spraw Wewnętrznych i Administracji z dnia 18 kwietnia 2005 r. w sprawie wzoru flagi oraz oznakowania jednostek pływających i statków powietrznych PolicjiRozporządzenie Ministra Infrastruktury z dnia 21 października 2005 r. w sprawie wzorów flag dla statków morskich na oznaczenie pełnionej specjalnej służby państwowej oraz okoliczności i warunków ich podnoszenia波兰旗帜波兰

          Indenting and Dedenting ASP code with Python