Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7869829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:26:30+00:00 2026-06-03T01:26:30+00:00

So I am writing a script that will curl a site I’ve written that

  • 0

So I am writing a script that will curl a site I’ve written that will return a string. I am using it to compare a value that is saved within a file. I am having trouble getting my conditional statement to return true for matching values.

Here is a snippet of my bash code

var1=$(curl -s -w %{http_code}\\n www.somesite.com)
var2=$(cat somefile)

if [[ "$var1" = "$var2" ]]; then
    echo "TRUE"
else
    echo "FALSE"
fi

I have manually looked at both the strings and they seem to be identical. I’ve done wc with all applicable options with it. I’ve copy and pasted both the values into Notepad++ and did a find for the expected string and it said that both values matched the find command.

Obviously, if I manually put the values in the condition it returns true, so I know its not my conditional statement.

My guess is there is some type of hidden character on the end of curl…(‘\r’ or ‘\n’ or something that I am unaware)…or maybe on the end of the file that I am unaware of. Is this a known issue when trying to compare curl output and file content?

This may be a dumb question, but for the life of me I cannot seem to get these strings to match doing it dynamically instead of hardcoding the values in the condition.

Any suggestions would be great. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:26:31+00:00Added an answer on June 3, 2026 at 1:26 am
    $ diff -q -b <(echo $'abc\ndef') <(echo $'abc\r\ndef') > /dev/null ; echo $?
    0
    $ diff -q -b <(echo $'abc\ndef') <(echo $'abc\r\nde') > /dev/null ; echo $?
    1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a script that will allow a user to input a string that
For a script that will check/set a Windows registry value. No GUI. Am writing
I'm writing a PowerShell script that will execute commands on a remote host using
I am writing a script that will look in a custom reports directory, copy
I'm writing a script that will ping my ip range. Here's what I have
I am writing a PowerShell script that will back up several folders from my
I amm writing a little python script that will grab information from VMs of
I'm writing a script and I need to create a loop that will execute
I am writing a script that will transfer a file from one server to
I am writing a PHP script that will send via a cron an email

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.