First, Thank you for your time and effort to help me with this situation. Now, without further ado, my issue.

I am a student in Cybersecurity and I am attempting to make bash script to enumerate my target host. I have several echo -e commands that repeat in function, but need to be where they are in the output file for clarity in my pentest report. Furthermore, I even have the command outputs headed to the appropriate files. My question is this:

How would I append the output of echo messages, like these below, to take their rightful place in both files? (this is a short excerpt)


Enum_Report=(Enum_Report-$(date "+%F-%H-%M-%S").txt)
Enum_Log=(Enum_Webserver_Log-$(date "+%F-%H-%M-%S").txt)
Err_Log=(Enum_Report_Error_Log-$(date "+%F-%H-%M-%S").txt)


echo -e "\nWhat's the kernel version? Is it 64-bit?\n" >> $Enum_Report >> $Err_Log

cat /proc/version
uname -a
uname -mrs
dmesg | grep Linux
ls /boot | grep vmlinuz-
} >> $Enum_Report 2>>$Err_Log

echo -e "\nWhats cached, IP and/or MAC addresses?\n" >>$Enum_Report >> $Err_Log

arp -e
/sbin/route -nee
} >> $Enum_Report 2>>$Err_Log


Currently echo outputs only to the $Err_Log, and I would like it to head every command group I use in both files. Basically, I would like to log all the commands I run from this script under headings and in two separate files. Redirecting stdout and stderr works fine to separate outputs from the command group into separate files. Surely, there has to be a simpler way to append the echo message to both files before the commands run, such that echo command stdout lands in $Enum_Report and $Err_Log and then the output from each of the command groups runs as normal.

Other information to note:

my target host is a virtual machine on the same network as my Kali-box, running Ubuntu 14.04.5 LTS

Thanks again,



1 Answer 1


You cannot redirect the output to more than one file, but you could use tee or tee -a.

echo -e "\nWhat's the kernel version? Is it 64-bit?\n" | tee -a $Enum_Report >> $Err_Log

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .