Rather than reading the whole log just to add a line to it, you can use >
to append to the end of the file.
function log()
{
local changelog="/run/media/jamie/DUAL/changelog"
if [ "$1" == "--view" ]; then
cat $changelog
else
echo "$(date +%D:%H:%M): $1" >> $changelog
fi
}
Also. If you do want to add an option to show the last few lines of the log using
tail
instead ofcat
will do it.