Sunday, May 5, 2024
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 7716  / 1 Year ago, sun, march 5, 2023, 5:35:09

How to create date type in bash?



what this date mean? '1803141400'



touch -t 1803141400 test1 test2


How can I compute time?


More From » command-line

 Answers
1

According to touch man page:



  -t STAMP
use [[CC]YY]MMDDhhmm[.ss] instead of current time


where:



CC: First two digit of the year
YY: Last two digits of the year
MM: Month (two-digit numeric month)
DD: Day (two-digit numeric day i.e. day of month)
hh: Hour
mm: Minutes
ss: Seconds


[] indicates that field is optional



In your examples 1803141400 means: 2018 mar 14, 14.00 and touch will change time stamp of test1 and test2 files according to this value.



$ ls -l test1 test2
-rw-rw-r-- 1 yourUser yourGroup 0 mar 14 2018 test1
-rw-rw-r-- 1 yourUser yourGroup 0 mar 14 2018 test2

[#23222] Sunday, March 5, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
uccase

Total Points: 473
Total Questions: 100
Total Answers: 110

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
uccase questions
;