shell下取得字符串的md5值
echo 123 | md5sum |
ba1f2511fc30423bdbb183fe33f3dd0f -
php -r “echo md5(‘123’);”
202cb962ac59075b964b07152d234b70
两者的md5值不一致,于是有很多有趣的解法:
1 Mysql解法:
mysql> select md5(‘123’);
+———————————-+
md5(‘123’) |
+———————————-+
202cb962ac59075b964b07152d234b70 |
+———————————-+
2 修正换行符法
[root@fetion ~]# printf 123 | md5sum |
202cb962ac59075b964b07152d234b70 -
[root@fetion ~]# echo -n 123 | md5sum |
202cb962ac59075b964b07152d234b70 -
[root@fetion ~]# echo 123 | tr -d ‘/n’ | md5sum |
202cb962ac59075b964b07152d234b70 -
小结一下:
1 echo默认是带换行符做结尾的
2 echo -n 可以去掉换行符
3 printf是没有换行符结尾的
4 tr可以删掉一个字符,如 tr -d ‘/n’
5 php命令行执行一段程序是 php -r “code”
[ ](http://technorati.com/tag/CentOS)
文章分类
标签云
Gray,
Public,
灰度发布,
灰度放量,
ABTest,
AB测试,
分流发布
CentOS,
Linux,
Shell
Mac,
Shell,
Vim
Linux
SSH
Mac
Mail
MacOSX
命令
MySQL,
调优
Apache,
HTTP,
ngnix
MySQL
gif,
jpeg,
png
Markdown
CentOS
PHP,
WordPress,
Blog
AsciiDoc,
mod_deflat
sudo
Leopard,
Snow
Leopard
Apache
Nginx,
木马
hostname,
upload
md5,
md5sum,
DNS
版本
Cookie,
PHP
Chrome
DooPHP,
CSS
Filter
IT
Java,
Maven,
Thrift
Git
Memcache
MongoDB
Node
Node.js
npm
HTML
Nginx
JDK,
Sublime
Timestamp
Lua,
Redis,
MacOSX,
Class,
Function
Sublime,
Snippets
ObjC
Cobar,
Bash
Brew,
Homebrew
AsciiDoc
Error
Yii
MacOSX,Hadoop,MapReduce
memcache,
Markdown,
Jekyll
VIM
Go,
Golang,
Redis
MacTeX,
CJK,
Tex
Tex,
LaTex
R,
Brew
Android,
Java
EC
Mou
GoAgentX,
GoAgent
Python
HBase
Markdown,Slide
Jenv
kerberos
Junit
Maven
虚拟化
LXC
Docker
bridge
AngularJS
PHPUnit
Android
composer
Golang
ReactNative,
项目管理
MAMP,
Memcache,
SecureCRT,
Zoc,
Mail,
GPG
Docker,
Supervisor
Test
Retail
Pay