saperlipopette saperlipopette - 2 months ago 30
Bash Question

Create a report log and manipulate it in a single script (Debian)

I would like to create a script, which will create a report file when launched. The name of the file would be something like


And the content would include the output of these commands :

service apache2 status
df -k
awk -F':' '{ print $1}' /etc/passwd

The problem is that i want to, in the same script, create a file and store things in it.
Here is what i already did :

filename = date +"Report-%Y-%M-%D"
service apache2 status > $filename

It tells me that the redirection is ambigous, and i saw stuff with _END at the end of the $filename, and i can't find how to resolve it.

Thank you in advance for any help


Try this:


filename="${path}Report-"$(date +%Y-%m-%d)
service apache2 status > "${filename}"
df -k >> "${filename}"
awk -F ':' '{print $1}' /etc/passwd >> "${filename}"

Of course you must change path var to put your directory. Must finish with "/" in this way.