Following doesn't work. I need to add a , and an input param at the end of the script. Please help
#!/bin/ksh
data_log="/usr/data/data_log.dbg"
err_file=开发者_如何学JAVA"/usr/data/data_log.err"
if [ $# -eq 1 ]; then
inParam=$1
fi
processInfo ${inParam} > ${data_log}
#Append ,inParam to each line in log for further processing
for logger in `cat ${data_log}`
{
echo ${logger} | sed s/$/,${inParam}/ >> ${err_file}
}
rm -rf ${data_log}
Replace the for logger in
loop where you're reading the file with this:
cat ${data_log} | while read line
do
echo "${line},${inParam}" >> ${err_file}
done
...which I think can be written like this (no shell to test with at the moment) to avoid a UUOC...
while read line
do
echo "${line},${inParam}" >> ${err_file}
done < ${data_log}
精彩评论