Hi,
i have written a script. it collects data based on the sql queries executed by it. i have multiple output files. after the output file is made i need to do some cosmetic changes in the files and then store them. i am unable to use sed conditions inside the loop.
see below code for storing the files.
backup_files()
{
for file in `ls tmp*`
do
mv $file `echo $file |sed 's/tmp/fnl/'`
if [[! -d "${BACKUP_DIR}" ]]
then
mkdir "${BACKUP_DIR}" && chmod 744 "${BACKUP_DIR}"
fi
mv fnl* "${BACKUP_DIR}"
done
}
nw see the code for doing the cosmetic changes in the output file, - this has to be done on each and every file. before taking its backup
cleanup()
{
sed -n '1,$s/^ *//gp' INFORM_${DATE}_${id} | sed -n '1,$s/ *|/|/gp' | sed -n '1,$s/| */|/gp' | sed -n '1,$s/ *$//gp' > INFORM_${DATE}_${id}.tmp
mv INFORM_${DATE}_{id}.tmp INFORM_${DATE}_{id}
sed -n '1,$s/NULL//gp' INFORM_${DATE}_{id} > INFORM_${DATE}_{_id}.tmp
mv INFORM_${DATE}_{id}.tmp INFORM_${DATE}_{id}
}
can some1 please help me with this. i am not sure how will i implement all the sed operations on all the files.
moreover, i am putting date here at the end of the file as suffix i want date in the below format but i unable to get tht .. please help me out with tht also.
date "+%Y%m%d%H%M%S"
not able to get this format at the end of the file.