Answers for "linux file timestamp"

1

bash get timestamp

# put current date as yyyy-mm-dd in $date
# -1 -> explicit current date, bash >=4.3 defaults to current time if not provided
# -2 -> start time for shell
printf -v date '%(%Y-%m-%d)T\n' -1 

# put current date as yyyy-mm-dd HH:MM:SS in $date
printf -v date '%(%Y-%m-%d %H:%M:%S)T\n' -1 

# to print directly remove -v flag, as such:
printf '%(%Y-%m-%d)T\n' -1
# -> current date printed to terminal
Posted by: Guest on November-25-2020
0

unix change timestamp of file

$ touch -d "2012-10-19 12:12:12.000000000 +0530" tgs.txt
Posted by: Guest on July-24-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language