in reply to More actions 1 of 50 Older › Date arithmetic advise/improvement - using stat ... calling the Perl script from a UNIX script

what am wanting to assign to the timediff variable in the UNIX script is the string "( 5 weeks, 3 days, 10:16:1 )" but only if the file is x days old. Do I need to have something like a return timediff_detail command

You could print the string to STDOUT and then capture it in the shell script via backticks (what you're doing already, actually).  (return is not for passing info from one process to another — if that's what you meant.)

As for assigning it only if it's x days old: you could "return" an empty string if it's not x days old, assign that to a temp variable first, and only copy the temp variable to the timediff variable if it's not empty. E.g.

#!/bin/sh timediff=foo tmpret=`timediff.pl $file` if [ "$tmpret" != "" ] ; then # empty? timediff=$tmpret fi echo $timediff
  • Comment on Re: More actions 1 of 50 Older › Date arithmetic advise/improvement - using stat ... calling the Perl script from a UNIX script
  • Select or Download Code