Linux Shell Scripting Command

jrustad24

New Member
Joined
Nov 14, 2020
Messages
4
Reaction score
0
Credits
43
I am having a problem getting the correct command to work with a shell script for the following. I need to save the text, "Logging Info:" with the current date and time to my file "logs.backup" inside my "LOGS" directory. Can anyone provide help with the correct command for this?
 


Bash:
echo"Logging info: $(date +%F-%T.%N)" >> /path/to/LOGS/logs.backup

Where /path/to/LOGS/logs.backup is the path to your logs.backup file.

I’m not sure what format you want the date in, but above, %F is the full date in yyyymmdd format. %T is the time and %N is the number of nanoseconds.

If you want the time stamp in any other format, take a look at the man page for the date command.
 
G'day @jrustad24 and welcome to linux.org :)

I am just moving this Thread to Command Line, where Scripting inquiries are handled.

Participants and Viewers will be notified.

Cheers

Chris Turner
wizardfromoz
 

Members online


Top