in reply to Converting multiple unix timestamps

Hello Maire

Condensing what you already have, a short oneliner makes the job done:

perl -pe "s/\b([0-9]{10})\b/localtime($1)/ge" file_with_timestamps.txt + > file_with_dates.txt

Generally I always use scalar localtime (time) but here there is no need. The above is already quoted for windows, where it seems you are (doublequotes for the oneliner).

L*

PS I had a mistake in the above oneliner perl -pne instead of perl -pe it worked the same way ( p overtake n ?). Npw corrected.

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Converting multiple unix timestamps -- oneliner
by Laurent_R (Canon) on Jul 28, 2018 at 18:16 UTC
    Hi Discipulus,

    I'm afraid you misread the question.

    It seems to me that your code will replace time stamps with date strings such as "Sat Jul 28 20:11:27 2018", but that's not what is desired: Maire wants something like "YYYY:MM:DD HH:MM:SS or similar."