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 7919489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:52:57+00:00 2026-06-03T15:52:57+00:00

I have a web application that is deployed to a server. I am trying

  • 0

I have a web application that is deployed to a server. I am trying to create a script that amoing other things reads the current version of the web application from a properties file that is deployed along with the application.

The file looks like this:

//other content
version=[version number]
build=[buildnumber]
//other content

I want to create a variable that looks like this: version-buildnumber

Here is my script for it:

VERSION_FILE=myfile

VERSION_LINE="$(grep "version=" $VERSION_FILE)"
VERSION=${VERSION_LINE#$"version="}
BUILDNUMBER_LINE=$(grep "build=" $VERSION_FILE)
BUILDNUMBER=${BUILDNUMBER_LINE#$"build="}
THEVERSION=${VERSION}-${BUILDNUMBER}

The strange thing is that this works in some cases but not in others.
The problem I get is when I am trying to concatenate the strings (i.e. the last line above). In some cases it works perfectly, but in others characters from one string replace the characters from the other instead of being placed afterwards.

It does not work in these cases:

  • When I read from the deployed file
  • If I copy the deployed file to another location and read from there

It does work in these cases:

  • If I write a file from scratch and read from that one.
  • If I create my own file and then copy the content from the deployed file into my created file.

I find this very strange. Is there someone out there recognizing this?

  • 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-03T15:52:58+00:00Added an answer on June 3, 2026 at 3:52 pm

    It is likely that your files have carriage returns in them. You can fix that by running dos2unix on the file.

    You may also be able to do it on the fly on the strings you’re retrieving.

    Here are a couple of ways:

    Do it with sed instead of grep:

    VERSION_LINE="$(sed -n "/version=/{s///;s/\r//g;p}" $VERSION_FILE)"
    

    and you won’t need the Bash parameter expansion to strip the “version=”.

    OR

    Do the grep as you have it now and do a second parameter expansion to strip the carriage return.

    VERSION=${VERSION_LINE#$"version="}
    VERSION=${VERSION//$'\r'}
    

    By the way, I recommend habitually using lowercase or mixed case variable names in order to reduce the chance of name collisions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a application that I deployed to web server. Users go to publish.htm
I have a web application that is deployed with web.config file. Are there any
I have a web application project (wap) that is successfully being deployed to a
I have an ASP.NET web application that, for whatever reason, when it is deployed
I have an ASP.Net web application that is deployed to a number of different
We have a web application deployed to a server, which was done via an
We have a web application deployed on a tomcat server. There are certain scheduled
I have developed an web application using JSP and deployed in tomcat server. In
I have a web service application that I deployed successfully on Apache Tomcat using
I have a web application that is deployed on WebSphere and that use one

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.