標籤:字串 code 斷行符號符 檔案中 加密 mysql blog shell rom
#!/bin/bashMYSQL=‘mysql -u*** -p*** -hws5 account‘tmp="tmp"resultsource="resultsource"resultdest="resultdest"echo "select user_id,phone_num,email from user_accounts where length(user_id) = 11 limit 1"|${MYSQL} > ${tmp}sed ‘1d‘ ${tmp} > ${resultsource}> ${resultdest} while read user_id phone_num emaildo echo ${user_id} `echo ROKID${phone_num}ACCOUNT` echo -n ROKID${phone_num}ACCOUNT|md5sum|cut -d" " -f 1|tr [a-z] [A-Z] echo ${user_id} `echo -n ROKID${phone_num}ACCOUNT|md5sum|cut -d" " -f 1|tr [a-z] [A-Z]` >> ${resultdest}done < ${resultsource}#while read user_id phone_num_md5 #do # echo "update user_accounts set phone_num = \"${phone_num_md5}\" where user_id = \"${user_id}\"" | $MYSQL #done < ${resultdest}
上面紅色加粗的語句,為正確的md5sum加密方法(特別注意前面echo -n 選項)
PS:MAC下在檔案中執行上面紅色加粗的選項,始終不能去掉字串後面的斷行符號符。
可通過xxd filename
或者od -c filename 查看是否有斷行符號符
未完待續。。。
shell echo -n md5sum使用方法