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?
 


JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,793
Reaction score
2,605
Credits
15,178
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.
 

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
9,169
Reaction score
8,119
Credits
39,329
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