in reply to Re: Epoch to specific output
in thread Epoch to specific output

Your suggestion works well with a direct input for time. However, I was unable to substitute time with the $x variable.

I was able to get it to work though with the following code:

echo $x|perl -MPOSIX -e 'print strftime("%m%d%H%M", gmtime <stdin>)'

Thank you everyone for your help!

Replies are listed 'Best First'.
Re^3: Epoch to specific output
by aitap (Curate) on Jan 02, 2014 at 21:01 UTC
    Pass your variable as an additional argument, use @ARGV to get it from inside the program:
    perl -MPOSIX -le'print strftime("%m%d%H%M", gmtime $ARGV[0])' "$x"
      Or just use shift:
      perl -MPOSIX -le 'print strftime("%m%d%H%M", gmtime shift)' "$x"
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ