shell echo -n md5sum使用方法


#!/bin/bash
MYSQL='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 email
do
  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 查看是否有回車符

 

未完待續。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM