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,704
Reaction score
2,471
Credits
13,677
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
8,627
Reaction score
7,586
Credits
35,284
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
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Top