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