Variable completely messes up echoed string2019 Community Moderator Electionusing awk to make new file, results in issues using 1 specific column, can't figure out what is wrongAppend 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

Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?

Worshiping one God at a time?

Unfrosted light bulb

Should I use acronyms in dialogues before telling the readers what it stands for in fiction?

Is it insecure to send a password in a `curl` command?

What does "^L" mean in C?

Optimising a list searching algorithm

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

Is it possible to stack the damage done by the Absorb Elements spell?

gerund and noun applications

How do hiring committees for research positions view getting "scooped"?

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

HP P840 HDD RAID 5 many strange drive failures

Suggestions on how to spend Shaabath (constructively) alone

Writing in a Christian voice

What is the relationship between relativity and the Doppler effect?

How can an organ that provides biological immortality be unable to regenerate?

Existence of a celestial body big enough for early civilization to be thought of as a second moon

Does the attack bonus from a Masterwork weapon stack with the attack bonus from Masterwork ammunition?

Geography in 3D perspective

Light propagating through a sound wave

Would it be believable to defy demographics in a story?

PTIJ: Why do we blow Shofar on Rosh Hashana and use a Lulav on Sukkos?

Can other pieces capture a threatening piece and prevent a checkmate?



Variable completely messes up echoed string



2019 Community Moderator Electionusing awk to make new file, results in issues using 1 specific column, can't figure out what is wrongAppend 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










5















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






















  • Next time when you see something like this, pipe the output to od or cat -A.

    – Weijun Zhou
    1 hour ago











  • Dupe unix.stackexchange.com/questions/312446/… and cross stackoverflow.com/questions/43837875/… (mine). bash can select characters without head or/and tail, and do case conversion without tr; awk can match like grep and do the CR removal; there are Qs on all of these.

    – dave_thompson_085
    4 mins ago
















5















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






















  • Next time when you see something like this, pipe the output to od or cat -A.

    – Weijun Zhou
    1 hour ago











  • Dupe unix.stackexchange.com/questions/312446/… and cross stackoverflow.com/questions/43837875/… (mine). bash can select characters without head or/and tail, and do case conversion without tr; awk can match like grep and do the CR removal; there are Qs on all of these.

    – dave_thompson_085
    4 mins ago














5












5








5








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 9 hours ago









user323587user323587

422




422












  • Next time when you see something like this, pipe the output to od or cat -A.

    – Weijun Zhou
    1 hour ago











  • Dupe unix.stackexchange.com/questions/312446/… and cross stackoverflow.com/questions/43837875/… (mine). bash can select characters without head or/and tail, and do case conversion without tr; awk can match like grep and do the CR removal; there are Qs on all of these.

    – dave_thompson_085
    4 mins ago


















  • Next time when you see something like this, pipe the output to od or cat -A.

    – Weijun Zhou
    1 hour ago











  • Dupe unix.stackexchange.com/questions/312446/… and cross stackoverflow.com/questions/43837875/… (mine). bash can select characters without head or/and tail, and do case conversion without tr; awk can match like grep and do the CR removal; there are Qs on all of these.

    – dave_thompson_085
    4 mins ago

















Next time when you see something like this, pipe the output to od or cat -A.

– Weijun Zhou
1 hour ago





Next time when you see something like this, pipe the output to od or cat -A.

– Weijun Zhou
1 hour ago













Dupe unix.stackexchange.com/questions/312446/… and cross stackoverflow.com/questions/43837875/… (mine). bash can select characters without head or/and tail, and do case conversion without tr; awk can match like grep and do the CR removal; there are Qs on all of these.

– dave_thompson_085
4 mins ago






Dupe unix.stackexchange.com/questions/312446/… and cross stackoverflow.com/questions/43837875/… (mine). bash can select characters without head or/and tail, and do case conversion without tr; awk can match like grep and do the CR removal; there are Qs on all of these.

– dave_thompson_085
4 mins ago











1 Answer
1






active

oldest

votes


















7














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
    9 hours ago






  • 3





    @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
    9 hours ago











  • Note use of CRLF line endings is common in Internet protocols, and in particular is required for content-type: text/plain in MIME (email, or news), see rfc2046 section 4.1.1. It not clear all MIME requirements should (or sometimes can) carry over to HTTP, but it is best to assume they do when there is no statement or clear evidence otherwise.

    – dave_thompson_085
    4 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









7














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
    9 hours ago






  • 3





    @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
    9 hours ago











  • Note use of CRLF line endings is common in Internet protocols, and in particular is required for content-type: text/plain in MIME (email, or news), see rfc2046 section 4.1.1. It not clear all MIME requirements should (or sometimes can) carry over to HTTP, but it is best to assume they do when there is no statement or clear evidence otherwise.

    – dave_thompson_085
    4 mins ago















7














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
    9 hours ago






  • 3





    @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
    9 hours ago











  • Note use of CRLF line endings is common in Internet protocols, and in particular is required for content-type: text/plain in MIME (email, or news), see rfc2046 section 4.1.1. It not clear all MIME requirements should (or sometimes can) carry over to HTTP, but it is best to assume they do when there is no statement or clear evidence otherwise.

    – dave_thompson_085
    4 mins ago













7












7








7







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 9 hours ago









Uncle BillyUncle Billy

7307




7307












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

    – user323587
    9 hours ago






  • 3





    @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
    9 hours ago











  • Note use of CRLF line endings is common in Internet protocols, and in particular is required for content-type: text/plain in MIME (email, or news), see rfc2046 section 4.1.1. It not clear all MIME requirements should (or sometimes can) carry over to HTTP, but it is best to assume they do when there is no statement or clear evidence otherwise.

    – dave_thompson_085
    4 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
    9 hours ago






  • 3





    @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
    9 hours ago











  • Note use of CRLF line endings is common in Internet protocols, and in particular is required for content-type: text/plain in MIME (email, or news), see rfc2046 section 4.1.1. It not clear all MIME requirements should (or sometimes can) carry over to HTTP, but it is best to assume they do when there is no statement or clear evidence otherwise.

    – dave_thompson_085
    4 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
9 hours ago





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

– user323587
9 hours ago




3




3





@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
9 hours 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
9 hours ago













Note use of CRLF line endings is common in Internet protocols, and in particular is required for content-type: text/plain in MIME (email, or news), see rfc2046 section 4.1.1. It not clear all MIME requirements should (or sometimes can) carry over to HTTP, but it is best to assume they do when there is no statement or clear evidence otherwise.

– dave_thompson_085
4 mins ago





Note use of CRLF line endings is common in Internet protocols, and in particular is required for content-type: text/plain in MIME (email, or news), see rfc2046 section 4.1.1. It not clear all MIME requirements should (or sometimes can) carry over to HTTP, but it is best to assume they do when there is no statement or clear evidence otherwise.

– dave_thompson_085
4 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

ValueError: Error when checking input: expected conv2d_13_input to have shape (3, 150, 150) but got array with shape (150, 150, 3)2019 Community Moderator ElectionError when checking : expected dense_1_input to have shape (None, 5) but got array with shape (200, 1)Error 'Expected 2D array, got 1D array instead:'ValueError: Error when checking input: expected lstm_41_input to have 3 dimensions, but got array with shape (40000,100)ValueError: Error when checking target: expected dense_1 to have shape (7,) but got array with shape (1,)ValueError: Error when checking target: expected dense_2 to have shape (1,) but got array with shape (0,)Keras exception: ValueError: Error when checking input: expected conv2d_1_input to have shape (150, 150, 3) but got array with shape (256, 256, 3)Steps taking too long to completewhen checking input: expected dense_1_input to have shape (13328,) but got array with shape (317,)ValueError: Error when checking target: expected dense_3 to have shape (None, 1) but got array with shape (7715, 40000)Keras exception: Error when checking input: expected dense_input to have shape (2,) but got array with shape (1,)

Ружовы пелікан Змест Знешні выгляд | Пашырэнне | Асаблівасці біялогіі | Літаратура | НавігацыяДагледжаная версіяправерана1 зменаДагледжаная версіяправерана1 змена/ 22697590 Сістэматыкана ВіківідахВыявына Вікісховішчы174693363011049382

Illegal assignment from SObject to ContactFetching String, Id from Map - Illegal Assignment Id to Field / ObjectError: Compile Error: Illegal assignment from String to BooleanError: List has no rows for assignment to SObjectError on Test Class - System.QueryException: List has no rows for assignment to SObjectRemote action problemDML requires SObject or SObject list type error“Illegal assignment from List to List”Test Class Fail: Batch Class: System.QueryException: List has no rows for assignment to SObjectMapping to a user'List has no rows for assignment to SObject' Mystery