I have 100 files, where i want to search a set of strings and make the replacement by other strings
In the first case I want to include a parameter in the name of a file
LOG_DCT = $ LOG_DIR/DCT_GERAL_"$DATAINI".log
replace to : LOG_DCT = $ LOG_DIR / DCT_GERAL_ $ 1_ "$ DATAINI". log
I did tests with the instruction "perl -pi -e 's/DCT_GERAL/DCT_GERAL_ $ 1 /' filename”, but the result is not what we expected: LOG_DCT = $ LOG_DIR / DCT_GERAL__" $ DATAINI”.log replaces the $ 1 by null.
In the second case, I want to move the instruction of new line to the end of a printf
printf "\n# $IDCADEIA - $IDJOB - $HORAACTUAL - XPTO(YYYYMMDD)">> $ LOGFILE
Replace to: printf "$IDCADEIA - $IDJOB - $HORAACTUAL - XPTO(YYYYMMDD) \n#">> $ LOGFILE
I tried using the command "perl -pi -e 's/printf "\n#/printf "/' filename” and "perl -pi -e' s/) ">> $ LOGFILE /) \n#"> > $ LOGFILE/' filename”, but since the string has special characters ( ), \ ", #) it gives an error in the replacement.
Accepted suggestions of how to make these changes to files without having to have them manually:
regards
Rui