Skip to main content
1 of 2
heemayl
  • 58.1k
  • 9
  • 129
  • 144

Assuming consistent file format, with bash you can read the file line by line, test if it's in given format and then do the conversion:

while IFS= read -r i; do [[ $i =~ ^#([0-9]{10})$ ]] && \
      date -d@"${BASH_REMATCH[1]}"; done <file.txt

BASH_REMATCH is an array whose first element is the first captured group in Regex matching, =~, in this case the epoch.

Example:

$ cat file.txt
#1472047795
ll /data/holding/email
#1472047906
cat /etc/rsyslog.conf
#1472048038
ll /data/holding/web

$ while IFS= read -r i; do [[ $i =~ ^#([0-9]{10})$ ]] && date -d@"${BASH_REMATCH[1]}"; done <file.txt
Wed Aug 24 20:09:55 BDT 2016
Wed Aug 24 20:11:46 BDT 2016
Wed Aug 24 20:13:58 BDT 2016
heemayl
  • 58.1k
  • 9
  • 129
  • 144