Skip to content

Instantly share code, notes, and snippets.

@from-unknown
Created July 28, 2020 09:07
Show Gist options
  • Save from-unknown/a9d623e0259b59d855c1ca8e47fe38af to your computer and use it in GitHub Desktop.
Save from-unknown/a9d623e0259b59d855c1ca8e47fe38af to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
input_file=$1
if ! [ $# -eq 1 ]; then
echo "Please specify INPUT_FILE"
echo Usage:
echo "$(basename $0)" INPUT_FILE
echo ex:
echo "$(basename $0)" unixtime.txt
echo ""
exit 1
fi
if ! [[ -f "${input_file}" ]]; then
echo file: ${input_file} does not exit
exit 1
fi
echo "" > ${input_file}_date.txt
while IFS= read -r line; do
date="$(date -r ${line} +"%Y-%m-%d %H:%M:%S")"
echo ${line} ${date}
echo ${date} >> ${input_file}_date.txt
done < ${input_file}
@from-unknown
Copy link
Author

input_file ex.

1595379363
1595379664
1595379765

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment