As a result of the work, write a script, the function of the script is to implement:
There are two. txt files, which contain some domain names, and then from these two. txt files, randomly remove a domain name, written to the shiting.htm and xiazai.htm files inside.
The script has been written, the grammar has been measured, no problem, the test passed in the virtual machine, no problem. But a copy into the production environment, there is a big problem. Tangled up my two days, now finally got the solution, now summarized below, lest make the same mistake again.
The script is as follows:
#!/bin/bash #
Author:honway.liu #
date:2012-06-01 #
Define location file
yyxz=/data/cdn/xiazai.txt
yyst=/data/cdn/shiting.txt
#xiazai =/data/api/xiazai.htm
#shiting =/data/api/shiting.htm
Xiazai =/tmp/xiazai.htm
shiting=/tmp/shiting.htm
log=/tmp
# Xiazai & shiting file line number
xznm=$ (wc-l $yyxz |awk ' {print} ')
stnm=$ (wc-l $yyst |awk ' {print} ')
# Random for Xiazai & shiting
down=$[$RANDOM% $xznm +1]
listen=$[ $RANDOM% $stnm +1]
# get Xiazai & shiting domain name
xzym=$ (sed-n ${down}p $yyxz)
stym=$ (Sed-n ${list En}p $yyst)
# Write domain name into HTM files.
Echo-n $xzym > $xiazai
echo-n $stym > $shiting
# out put logs
echo "The $xzym at ' date + '%F%T ' is Provided ">>/$log/xiazai_domain.log
echo" The $stym at ' date + '%F%T ' to provided ' >>/$log/shiting_dom Ain.log
Exit 0
This column more highlights: http://www.bianceng.cn/OS/Linux/
Grammar checking is fine, but when it's done, it's messy.
The last mistake above is because exit0 has no spaces. See the results of the SED is OK, but the contents of the variable is a mess, people have a headache. Look at the results of the output