I'm new to bash scripting and I've been trying to print out the entire line but couldn't find a way to work.
This is my code
#!/bin/bash
MOTD=`cat /etc/motd | awk '{print $1}'`
if [ "$MOTD" = "WARNING" ]
then
echo "Audit Criteria: Warning banner exist."
echo "Vulnerability: No."
echo "Details: $MOTD "
else
echo "Audit Criteria: Warning banners does not exist."
echo "Vulnerability: Yes."
echo "Details: $MOTD "
fi
my output is:
Audit Criteria: Warning banner exist.
Vulnerability: No.
Details: WARNING:
instead of the WARNING:Authorized uses only
All activity may be monitored and reported.
, only "WARNING" appeared in the Details:
I believe the problem lies on the
MOTD=`cat /etc/motd | awk '{print $1}'`
and
if [ "$MOTD" = "WARNING" ]
parts, I've tried {print$0}
but still could not get it to work.