Bash script function return value problem
- by Eedoh
Hi to all.
Can anyone help me return the correct value from a bash script function?
Here's my function that should return first (and only) line of the file passed as an argument:
LOG_FILE_CREATION_TIME()
{
return_value=`awk 'NR==1' $1`
return return_value
}
And here's my call of that function in the other script:
LOG_FILE_CREATION_TIME "logfile"
timestamp=$?
echo "Timestamp = $timestamp"
I always get some random values with this code. If, for example, there's a value of 62772031 in the "logfile", I get
Timestamp = 255
as an output. For some other values in the file, I get other random values as a return value, never the correct one.
Any ideas?