Hi, All:
Please check this script, to see what's the problem, I think it is right, but the running result makes me sad!!
(1)the source code
#!/bin/ksh
LDIF_LIST="/tmp/myfile"
for item in ${LDIF_LIST}
do
if [ -f ${item} ]; then
crtfile=`basename ${item}`
cp ${item} /tmp/${crtfile}.tmp.$$ 2>&-
cat /tmp/${crtfile}.tmp.$$ |
awk '{if (substr($0,1,1)!=" ") { printf "\n"; printf "%s" $0 }
else
if (substr($0,2,1)==" " ) { printf "%s", substr($0,3,10000) }
else { printf "%s", substr($0,2,10000) }
}END{printf "\n" }' | sed "s/host/room/g" > ${item}
fi
done
(2)the result when I run the -vx to debug:
awk: + 1>/tmp/myfile
not enough arguments in printf(%s)
record number 1
I THINK THERE IS NO PROBLEM WITH MY printf usage,but why it said "not enough arguments in printf(%s)"???
AND HOW SHOULD WE USE if-else statement in AWK ???Is there anything wrong???
THANKS A LOT! I AM CONFUSED!
Please check this script, to see what's the problem, I think it is right, but the running result makes me sad!!
(1)the source code
#!/bin/ksh
LDIF_LIST="/tmp/myfile"
for item in ${LDIF_LIST}
do
if [ -f ${item} ]; then
crtfile=`basename ${item}`
cp ${item} /tmp/${crtfile}.tmp.$$ 2>&-
cat /tmp/${crtfile}.tmp.$$ |
awk '{if (substr($0,1,1)!=" ") { printf "\n"; printf "%s" $0 }
else
if (substr($0,2,1)==" " ) { printf "%s", substr($0,3,10000) }
else { printf "%s", substr($0,2,10000) }
}END{printf "\n" }' | sed "s/host/room/g" > ${item}
fi
done
(2)the result when I run the -vx to debug:
awk: + 1>/tmp/myfile
not enough arguments in printf(%s)
record number 1
I THINK THERE IS NO PROBLEM WITH MY printf usage,but why it said "not enough arguments in printf(%s)"???
AND HOW SHOULD WE USE if-else statement in AWK ???Is there anything wrong???
THANKS A LOT! I AM CONFUSED!