I want to capture and write my error to log file along with custom message.
Consider the command :
$(find $val -type f -delete) || echo "error in deleting files" |tee -a log.txt
This command writes below line in log.txt file
error in deleting files
But I also want to print the error of find command to log filealong with my custom message , so that log file can look like this:
find: `/home/temp': No such file or directory
error in deleting files
||
– Francesco May 22 '20 at 09:47