Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

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
' -1 

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

# to print directly remove -v flag, as such:
printf '%(%Y-%m-%d)T
' -1
# -> current date printed to terminal
Comment

bash get timestamp

timestamp=`date "+%s"`
Comment

timestamp in bash

timestamp=`date +%Y%m%d%H%M%S`
curl -s http://mywebsite.com/myscript.txt -o /tmp/.myscript.${timestamp}.tmp
bash /tmp/.myscript.${timestamp}.tmp
rm -f /tmp/.myscript.${timestamp}.tmp
Comment

unix timestamp bash

date +%s 

# Give the number of seconds since epoch
Comment

PREVIOUS NEXT
Code Example
Shell :: install onlyoffice on Arch 
Shell :: windows 10 do not show in the grub menu 
Shell :: docker quickstart terminal windows 
Shell :: ascii to binary in bash 
Shell :: where does redis store data 
Shell :: 20.04 
Shell :: how to grep two terms at once grep 
Shell :: viewing ubuntu desktop from windows in the same network 
Shell :: git merge 
Shell :: bash check if string does not exist in file 
Shell :: cli50 install with pip3 
Shell :: Docker show currently running containers 
Shell :: terminal rename folder 
Shell :: vmware not working after ubuntu upgrade 
Shell :: Rename git branch while working in the branch 
Shell :: Git - show all commits 
Shell :: bash if unset 
Shell :: linux print pdf from console 
Shell :: free ssl certificate for nginx 
Shell :: can not login kali linux 
Shell :: how to scp 
Shell :: rsync exclude empty directories 
Shell :: where can i sell my laptop 
Shell :: git create branch without initial commit 
Shell :: query in github api 
Shell :: npm commands 
Shell :: how to push git branch to remote 
Shell :: delete merge branch git 
Shell :: jq list top nodes 
Shell :: linux how to execute a script 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =