you can use date
:
reut@EliteBook-8470p:~/$ for epoch in $(cat f.txt | cut -d' ' -f 3); do date -d @$epoch +%d/%m/%y; done
Pipeline walkthourgh:
$(cat f.txt | cut -d' ' -f 3)
takes each 3rd column in every line split by ' '
as dlimiter. This is the epoch string you have.
Now use each of these (using a for
loop) as an argument to date -d @<eopch>
and set the format to %d/%m/%y
.
Output:
30/11/11
30/11/11
30/11/11
30/11/11
Edit: To actually store this in a result file:
while read serial name tdate; do echo ${serial} ${name} $(date -d@"${tdate}" "+%d/%m/%y") >> result_file; done < your_file.txt
Now your output is in result file.
Output in result_file
:
1 aaa 30/11/11
2 bbb 30/11/11
3 ccc 30/11/11
4 ddd 30/11/11
Thanks @fedorqui.