I am trying to optimize my script that loops through a folder and extracts only the part of a file name before a date and the header of the file and outputs it into a different file using a delimiter. I feel the script is robust and I want to refactor it. If there is also a better way, please tell me.#!/bin/bash# script variablesFOLDER=path/to/folderLOG_FILE=path/to/logfile.csv# Getting the pattern and  header of files from FOLDERfor file in `ls $FOLDER/*.csv`do    echo -n $(basename $file) 2>&1 | sed -r 's/(.*)_[0-9]{8}_[0-9][0-9]-[0-9][0-9].[0-9][0-9].csv/\1/'  | tee -a $LOG_FILE    echo -n | | tee -a $LOG_FILE    cat $file | head -1 | tee -a $LOG_FILEdone #> $LOG_FILE
Optimize bash script that concatenates output
bash;shell;posix;sh