In my files commands are like :
File1.sh:
log_file='20210101'
echo -e "
Output is
" >> $log_file 2>&1
File2.sh
echo "Something"
log_file='20210102'
hive -e -f my_file_name.hql >> $log_file 2>&1
File3.sh
cat myfile
echo "something"
ehco "new line"
log_file='2021-01-01_23_59_59'
hive -e "Select * from tables' >> $log_file 2>&1
I am looking for a command to remove the line where defined variable 'log_file' from all the files
AND
remove only '>> $log_file 2>&1' part from all the files
Output in files:
File1.sh:
echo -e "
Output is
"
File2.sh
echo "Something"
hive -e -f my_file_name.hql
File3.sh
cat myfile
echo "something"
ehco "new line"
hive -e "Select * from tables'
I tried multiple ways with sed but nothing worked, few of them are :
I tried :
sed -e 's/*[>> $]log_file//g' test.sh
sed -e 's/*[>> $]log_file[ 2>&1]//g' test.sh
sed -e 's/>> $log_file 2>$//' test.sh
sed -e 's/">> $log_file 2>&1"/""/g' test.sh
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…