mac下的tree命令

在默认安装安装的mac下没有找到tree命令,找了一下原来有个比较流氓的解决办法: find . -print | sed -e ‘s;[^/]*/;|____;g;s;____|; |;g’ 这个命令行跑起来类似平常tree的效果,比如: . |____extra | |____httpd-autoindex.conf | |____httpd-dav.conf | |____httpd-default.conf | |____httpd-info.conf | |____httpd-languages.conf | |____httpd-manual.conf | |____httpd-mpm.conf | |____httpd-multilang-errordoc.conf | |____httpd-ssl.conf | |____httpd-userdir.conf | |____httpd-vhosts.conf |____httpd.conf |____magic |____mime.types |____original | |____extra | | |____httpd-autoindex.conf | | |____httpd-dav.conf | | |____httpd-default.conf | | |____httpd-info.conf | | |____httpd-languages.conf […]

混合使用SQL和shell命令

mysql下可以用批处理模式运行SQL,比如: shell> mysql -h host -u user -p < batch-file.sql Enter password: ******** 但是平常往往需要在执行sql的同时,运行一些shell脚本进行进一步计算,保存日志之类的。这个可以靠mysql的system命令来实现,例如: # Mixing shell commands and SQL queries in batch mode- demo script use test; #INSTALL PLUGIN example SONAME ‘ha_example.so’; #Ignore statement system cp /tmp/mysqld.trace logs/init.trace # Shell commands prefixed with a ‘system’ create table new4(num integer) engine=EXAMPLE; system cp /tmp/mysqld.trace logs/after_create.trace […]

在命令行里执行mysql的sql

平常执行sql,需要登录到mysql的shell下,然后再执行。比如: $ /usr/bin/mysql -u root mysql> select * from users; 但是如果写一点简单的脚本,也可以在命令行下直接运行sql并显示结果,比如: $ cat executemysql.sh #!/bin/sh qry=$1; echo “Executing the following query” echo “$qry” mysql -u root