Hi,

check_time()
{
 fileName=$myFileName
newTime=$line
newtimeaccess="date --date \"$newTime 6 hour\" '+%Y-%m-%d %H:%M:%S'"
newtimeaccess=`echo $newtimeaccess | sh`
strnewtime=$(date -d "$newtimeaccess" +%s)
systime=$(date  +%s)
if [ $systime -le $strnewtime ]
then
        return "$fileName__0";
else
        return "$fileName__1";
fi
}

value=`check_time "$myFileName $line"`
##$myFileName -- file name and $line -- time of file

echo $value;

It giving error return: : numeric argument required
How to solve It

You can not return a string. You must return a numeric value. So changing "$fileName__0" to something like 0 would work.

You can of course "return" a string like this.. which is not really returning and it forces you to ensure that there are no unwanted `echo`s in the function.. but it works.. :)

#!/bin/bash

function gimme_string() {
    echo "returned string"
}

my_string=`gimme_string`

echo "String I got is: $my_string"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.