So I have a script that generates a report about a folder date,folder size, and disk space.

I don't understand how to get the date and time the report was generated and My script correctly outputs the result for the rest that i wanted.


For date and time you can make the following changes in your code:
Add this line after #!/bin/bash

echo $(date '+%d/%m/%Y %H:%M:%S')

And then your code should look like this:


echo $(date '+%d/%m/%Y %H:%M:%S')
du -sh /Magna
df -h /Magna
  • 2
    There's really no need to save the output of the date command to a variable, and then echo it out again – steeldriver Mar 29 '19 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.