my $emd = `date --date '-30 min' +'%H'`; chop ($emd); $emd = "/tmp/pathtomyfiles/$emd.txt"; #### johngg@shiraz:~/perl/utils > perl -Mstrict -Mwarnings -MPOSIX=strftime -E ' my $emd = strftime q{/tmp/pathtomyfiles/%H.txt}, localtime( time() - 1800 ); say $emd;' /tmp/pathtomyfiles/10.txt