Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6946134
  • 博文数量: 701
  • 博客积分: 10821
  • 博客等级: 上将
  • 技术积分: 12021
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-02 10:41
个人简介

中科院架构师,专注企业数字化各个方面,MES/ERP/CRM/OA、物联网、传感器、大数据、ML、AI、云计算openstack、Linux、SpringCloud。

文章分类

全部博文(701)

分类: 架构设计与优化

2015-09-04 19:43:39

1、vagrant建立简单httpserver方法:

1)映射端口

 修改Vagrantfile, 末尾添加本地端口和虚机端口的映射关系, 然后执行vagrant reload.  

 Vagrant::Config.run do |config|
        # Forward guest port 8000 to host port 8000
        config.vm.forward_port 8000, 8000
   end 

2)启动HTTPServer

    通过python自带web服务器SimpleHTTPServer,在特定目录下(建立一个index.html)输入下面的命令来启动web服务器,提供一个文件浏览的web服务。

    $python -m SimpleHTTPServer 8000

    然后在浏览器输入

    就可以看到上述目录下的所有目录和文件了,-m用于指定端口。

2、强大的parallel

1)parallel用于并行执行命令,加快处理速度,但是每次都会提示版权信息,可以用--bibtex后输入will cite,去除版权提示。

$ parallel --bibtex When using programs that use GNU Parallel to process data for publication please cite:

@article{Tange2011a,
title = {GNU Parallel - The Command-Line Power Tool},
author = {O. Tange},
address = {Frederiksberg, Denmark},
journal = {;login: The USENIX Magazine},
month = {Feb},
number = {1},
volume = {36},
url = {},
year = {2011},
pages = {42-47}
}

(Feel free to use \nocite{Tange2011a})

This helps funding further development.

Type: 'will cite' and press enter.
> will cite Thank you for your support. It is much appreciated. The citation
notice is now silenced.

这样以后就不会每次命令提示版权信息。 

parallel命令的用法比较

$find data -name '*.txt' -exec echo "Processin {}" \;

$find data -name '*.txt' -print0 | parallel -0 echo "Processin {}"

如果采用exec参数的话,注意-exec 最后结尾为一个空格加“\”加“;”,因为;可能在不同shell有不同解释,加上\来转义,确保exec参数之后的命令能正确执行。

 3、神器jq来处理json

1)  jq .格式化显示json数据,瞬间觉得json数据可读了;

2)  curl -s " | jq -c '.list[] | {temp: .main.temp,weather: .weather[].description,time: .dt_txt}'| json2csv -p -k temp,weather,time >forecast.csv

curl 中含有&注意一定要""包含起来;

jq -c 压缩显示,不分行显示,注意:[] .的使用与json文件中一致

阅读(2693) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~