Mongo Shell基本操作
2015年3月4日
没有评论
1.查看数据库
> show dbs
admin (empty)
book 0.0625GB
demo 0.0625GB
local 0.0625GB
test 0.0625GB
2.切换数据库
> use demo
switched to db demo
3.查看数据库存在的表
> show collections
system.indexes
3.插入数据
在表中插入数据时,表如果不存在会自动创建
[......]
python命令补全
2015年2月9日
没有评论
1.在opt目录下新建.pystartup.py文件
2.编写该文件,内容如下:
#!/usr/bin/python import rlcompleter, readline readline.parse_and_bind('tab: complete')
3.在文件中/etc/bashrc添加环境变量
export PYTHONSTARTUP=/opt/.pystartup.py
4.使用source命令使新增的环境变量生效
[tom@Server ~]$ source /etc/bashrc
5.输入p[......]
sort和uniq命令
2015年2月8日
没有评论
sort命令主要是给给定的文档排序
测试文件:
Thomas:100:Marketing Alex Jason:200:Sales Blex Jason:200:Sales Madison Randy:300:Product Development Sanjay Gupta:400:Support Nisha Singh:500:Sales
默认的排序是正序,将每一个行看作一个整体
[root@Server1 Documents]# sort emp.txt Alex Jason:200:Sales Blex Jason:200:[......]
SHELL 条件测试
2015年2月6日
没有评论
1.语法:
test 表达式
[ 表达式 ]
[[ 表达式 ]]
根据$?返回的值0表示真,1表示假
2.两个数值比较
-eq 等于
-ne 不等于
-ge 大于等于
-gt 大于
-le 小于等于
-lt 小于
[test@demo ~]$ [ 3 -eq[......]
SHELL变量之数组
2015年2月5日
没有评论
1.数组的定义
1.1.定义同时赋多个值
[test@Server1 shell]$ names=(tom jack lili)
注意:数组的元素以空格作为分隔符。下标从0开始
1.2按索引赋值
[root@Server1 jdk1.6.0_45]# names[0]=tom [root@Server1 jdk1.6.0_45]# names[1]=jack [root@Server1 jdk1.6.0_45]# names[5]=lily
注意:自定义索引时,索引可以不连续
1.3.定义同时使用通配符赋[......]