Question

This is my first question on StackOverflow. I am pretty sure it would have been answered already (it is a pretty dumb question, I think, as I just started to learn Linux scripting), but I did'nt succeed to find an answer yet.

Sorry for that.

Here is my problem: I try to use in a shell a number given in a property file, I have an error because the number is not taken "as it is".

I have a prop.properties file :

sleepTimeBeforeLoop=10

and a test.sh shell :

#!/bin/sh
. prop.properties

echo "time="$sleepTimeBeforeLoop
sleep $sleepTimeBeforeLoop

When I launch test.sh I have the following Output:

time=10
sleep: invalid time interval `10\r'
Try `sleep --help' for more information.

What I understand is that my properties files was correctly sourced, but that the property was taken as a string, with some special character to indicate the end of the line, or whatever.

How can I do to take only the "10" value?

Thank you in advance for your answer.

Was it helpful?

Solution

This is line endings issue / make sure your script files are terminated by \n (the unix way) eg. write it in UNIX text editor or use a windows one capable of saving in "unix style"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top