zoukankan      html  css  js  c++  java
  • 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 查看是否有回车符

    未完待续。。。

  • 相关阅读:
    01 Vue的起步和插值表达式
    06 扩展的对象的功能
    05 解构赋值
    04 函数之扩展运算符、箭头函数
    03 函数之默认值、剩余参数
    02 模板字符串
    01 let和const命令
    28 Bootstrap排版
    27 Bootstrap的列偏移
    26 Bootstrap的栅格系统
  • 原文地址:https://www.cnblogs.com/zhzhang/p/6869655.html
Copyright © 2011-2022 走看看