diff --git a/published/20160303 Top 5 open source command shells for Linux.md b/published/20160303 Top 5 open source command shells for Linux.md new file mode 100644 index 0000000000..ec6aa3517a --- /dev/null +++ b/published/20160303 Top 5 open source command shells for Linux.md @@ -0,0 +1,86 @@ +Linux 下五个顶级的开源命令行 Shell +=============================================== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/terminal_blue_smoke_command_line_0.jpg?itok=u2mRRqOa) + +这个世界上有两种 Linux 用户:敢于冒险的和态度谨慎的。 + +其中一类用户总是本能的去尝试任何能够戳中其痛点的新选择。他们尝试过不计其数的窗口管理器、系统发行版和几乎所有能找到的桌面插件。 + +另一类用户找到他们喜欢的东西后,会一直使用下去。他们往往喜欢所使用的系统发行版的默认配置。最先熟练掌握的文本编辑器会成为他们最钟爱的那一个。 + +作为一个使用桌面版和服务器版十五年之久的 Linux 用户,比起第一类来,我无疑属于第二类用户。我更倾向于使用现成的东西,如此一来,很多时候我就可以通过文档和示例方便地找到我所需要的使用案例。如果我决定选择使用非费标准的东西,这个切换过程一定会基于细致的研究,并且前提是来自好基友的大力推荐。 + +但这并不意味着我不喜欢尝试新事物并且查漏补失。所以最近一段时间,在我不假思索的使用了 bash shell 多年之后,决定尝试一下另外四个 shell 工具:ksh、tcsh、zsh 和 fish。这四个 shell 都可以通过我所用的 Fedora 系统的默认库轻松安装,并且他们可能已经内置在你所使用的系统发行版当中了。 + +这里对它们每个选择都稍作介绍,并且阐述下它适合做为你的下一个 Linux 命令行解释器的原因所在。 + +### bash + +首先,我们回顾一下最为熟悉的一个。 [GNU Bash][1],又名 Bourne Again Shell,它是我这些年使用过的众多 Linux 发行版的默认选择。它最初发布于 1989 年,并且轻松成长为 Linux 世界中使用最广泛的 shell,甚至常见于其他一些类 Unix 系统当中。 + +Bash 是一个广受赞誉的 shell,当你通过互联网寻找各种事情解决方法所需的文档时,总能够无一例外的发现这些文档都默认你使用的是 bash shell。但 bash 也有一些缺点存在,如果你写过 Bash 脚本就会发现我们写的代码总是得比真正所需要的多那么几行。这并不是说有什么事情是它做不到的,而是说它读写起来并不总是那么直观,至少是不够优雅。 + +如上所述,基于其巨大的安装量,并且考虑到各类专业和非专业系统管理员已经适应了它的使用方式和独特之处,至少在将来一段时间内,bash 或许会一直存在。 + +### ksh + +[KornShell][4],或许你对这个名字并不熟悉,但是你一定知道它的调用命令 ksh。这个替代性的 shell 于 80 年代起源于贝尔实验室,由 David Korn 所写。虽然最初是一个专有软件,但是后期版本是在 [Eclipse Public 许可][5]下发布的。 + +ksh 的拥趸们列出了他们觉得其优越的诸多理由,包括更好的循环语法,清晰的管道退出代码,处理重复命令和关联数组的更简单的方式。它能够模拟 vi 和 emacs 的许多行为,所以如果你是一个重度文本编辑器患者,它值得你一试。最后,我发现它虽然在高级脚本方面拥有不同的体验,但在基本输入方面与 bash 如出一辙。 + +### tcsh + +[tcsh][6] 衍生于 csh(Berkely Unix C shell),并且可以追溯到早期的 Unix 和计算机时代开始。 + +tcsh 最大的卖点在于它的脚本语言,对于熟悉 C 语言编程的人来说,看起来会非常亲切。tcsh 的脚本编写有人喜欢,有人憎恶。但是它也有其他的技术特色,包括可以为 aliases 添加参数,各种可能迎合你偏好的默认行为,包括 tab 自动完成和将 tab 完成的工作记录下来以备后查。 + +tcsh 以 [BSD 许可][7]发布。 + +### zsh + +[zsh][8] 是另外一个与 bash 和 ksh 有着相似之处的 shell。诞生于 90 年代初,zsh 支持众多有用的新技术,包括拼写纠正、主题化、可命名的目录快捷键,在多个终端中共享同一个命令历史信息和各种相对于原来的 bash 的轻微调整。 + +虽然部分需要遵照 GPL 许可,但 zsh 的代码和二进制文件可以在一个类似 MIT 许可证的许可下进行分发; 你可以在 [actual license][9] 中查看细节。 + +### fish + +之前我访问了 [fish][10] 的主页,当看到 “好了,这是一个为 90 后而生的命令行 shell” 这条略带调侃的介绍时(fish 完成于 2005 年),我就意识到我会爱上这个交互友好的 shell 的。 + +fish 的作者提供了若干切换过来的理由,这些理由有点小幽默并且能戳中笑点,不过还真是那么回事。这些特性包括自动建议(“注意, Netscape Navigator 4.0 来了”,LCTT 译注:NN4 是一个重要版本。),支持“惊人”的 256 色 VGA 调色,不过也有真正有用的特性,包括根据你机器上的 man 页面自动补全命令,清除脚本和基于 web 界面的配置方式。 + +fish 的许可主要基于 GPLv2,但有些部分是在其他许可下的。你可以查看资源库来了解[完整信息][11]。 + +*** + +如果你想要寻找关于每个选择确切不同之处的详尽纲要,[这个网站][12]应该可以帮到你。 + +我的立场到底是怎样的呢?好吧,最终我应该还是会重新投入 bash 的怀抱,因为对于大多数时间都在使用命令行交互的人来说,切换过程对于编写高级的脚本能带来的好处微乎其微,并且我已经习惯于使用 bash 了。 + +但是我很庆幸做出了敞开大门并且尝试新选择的决定。我知道门外还有许许多多其他的东西。你尝试过哪些 shell,更中意哪一个?请在评论里告诉我们。 + +--- + +via: https://opensource.com/business/16/3/top-linux-shells + +作者:[Jason Baker][a] +译者:[mr-ping](https://github.com/mr-ping) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/jason-baker + +[1]: https://www.gnu.org/software/bash/ +[2]: http://mywiki.wooledge.org/BashPitfalls +[3]: http://www.gnu.org/licenses/gpl.html +[4]: http://www.kornshell.org/ +[5]: https://www.eclipse.org/legal/epl-v10.html +[6]: http://www.tcsh.org/Welcome +[7]: https://en.wikipedia.org/wiki/BSD_licenses +[8]: http://www.zsh.org/ +[9]: https://sourceforge.net/p/zsh/code/ci/master/tree/LICENCE +[10]: https://fishshell.com/ +[11]: https://github.com/fish-shell/fish-shell/blob/master/COPYING +[12]: http://hyperpolyglot.org/unix-shells + diff --git a/published/20160531 Why Ubuntu-based Distros Are Leaders.md b/published/20160531 Why Ubuntu-based Distros Are Leaders.md new file mode 100644 index 0000000000..c909e753f7 --- /dev/null +++ b/published/20160531 Why Ubuntu-based Distros Are Leaders.md @@ -0,0 +1,63 @@ +为什么 Ubuntu 家族会占据 Linux 发行版的主导地位? +========================================= + +在过去的数年中,我体验了一些优秀的 Linux 发行版。给我印象最深刻的是那些由强大的社区维护的发行版,而流行的发行版比强大的社区给我的印象更深。流行的 Linux 发行版往往能吸引新用户,这通常是由于其流行而使得使用该发行版会更加容易。并非绝对如此,但一般来说是这样的。 + +说到这里,首先映入我脑海的一个发行版是 [Ubuntu][1]。其基于健壮的 [Debian][2] 发行版构建,它不仅成为了一个非常受欢迎的 Linux 发行版,而且它也衍生出了不可计数的其他分支,比如 Linux Mint 就是一个例子。在本文中,我会探讨为何我认为 Ubuntu 会赢得 Linux 发行版之战的原因,以及它是怎样影响到了整个 Linux 桌面领域。 + +### Ubuntu 易于使用 + +在我几年前首次尝试使用 Ubuntu 前,我更喜欢使用 KED 桌面。在那个时期,我接触的大多是这种 KDE 桌面环境。主要原因还是 KDE 是大多数新手容易入手的 Linux 发行版中最受欢迎的。这些新手友好的发行版有 Knoppix、Simply Mepis、Xandros、Linspire 以及其它的发行版等等,这些发行版都推荐他们的用户去使用广受欢迎的 KDE。 + +现在 KDE 能满足我的需求,我也没有什么理由去折腾其他的桌面环境。有一天我的 Debian 安装失败了(由于我个人的操作不当),我决定尝试开发代号为 Dapper Drake 的 Ubuntu 版本(LCTT 译注:Ubuntu 6.06 - Dapper Drake,发布日期:2006 年 6 月 1 日),每个人都对它赞不绝口。那个时候,我对于它的印象仅限于屏幕截图,但是我想试试也挺有趣的。 + +Ubuntu Dapper Drake 给我的最大的印象是它让我很清楚地知道每个东西都在哪儿。记住,我是来自于 KDE 世界的用户,在 KDE 上要想改变菜单的设置就有 15 种方法 !而 Ubuntu 上的 GNOME 实现极具极简主义的。 + +时间来到 2016 年,最新的版本号是 16.04:我们有了好几种 Ubuntu 特色版本,也有一大堆基于 Ubuntu 的发行版。所有的 Ubuntu 特色版和衍生发行版的共同具有的核心都是为易用而设计。发行版想要增大用户基数时,这就是最重要的原因。 + +### Ubuntu LTS + +过去,我几乎一直坚持使用 LTS(Long Term Support)发行版作为我的主要桌面系统。10月份的发行版很适合我测试硬盘驱动器,甚至把它用在一个老旧的手提电脑上。我这样做的原因很简单——我没有兴趣在一个正式使用的电脑上折腾短期发行版。我是个很忙的家伙,我觉得这样会浪费我的时间。 + +对于我来说,我认为 Ubuntu 提供 LTS 发行版是 Ubuntu 能够变得流行的最大的原因。这样说吧———给普罗大众提供一个桌面 Linux 发行版,这个发行版能够得到长期的有效支持就是它的优势。事实上,不只 Ubuntu 是这样,其他的分支在这一点上也做的很好。长期支持策略以及对新手的友好环境,我认为这就为 Ubuntu 的普及带来了莫大的好处。 + +### Ubuntu Snap 软件包 + +以前,用户会夸赞可以在他们的系统上使用 PPA(personal package archive 个人软件包档案)获得新的软件。不好的是,这种技术也有缺点。当它用在各种软件名称时, PPA 经常会找不到,这种情况很常见。 + +现在有了 [Snap 软件包][3] 。当然这不是一个全新的概念,过去已经进行了类似的尝试。用户可以在一个长期支持版本上运行最新的软件,而不必去使用最新的 Ubuntu 发行版。虽然我认为目前还处于 Snap 软件包的早期,但是我很期待可以在一个稳定的发行版上运行的崭新的软件。 + +最明显的问题是,如果你要运行很多软件,那么 Snap 包实际会占用很多硬盘空间。不仅如此,大多数 Ubuntu 软件仍然需要由官方从 deb 包进行转换。第一个问题可以通过使用更大的硬盘空间得到解决,而后一个问题的解决则需要等待。 + +### Ubuntu 社区 + +首先,我承认大多数主要的 Linux 发行版都有强大的社区。然而,我坚信 Ubuntu 社区的成员是最多样化的,他们来自各行各业。例如,我们的论坛包括从苹果硬件支持到游戏等不同分类。特别是这些专业的讨论话题还非常广泛。 + +除过论坛,Ubuntu 也提供了一个很正式的社区组织。这个组织包括一个理事会、技术委员会、[本地社区团队][4]和开发者成员委员会。还有很多,但是这些都是我知道的社区组织部分。 + +我们还有一个 [Ubuntu 问答][5]版块。我认为,这种功能可以代替人们从论坛寻求帮助的方式,我发现在这个网站你得到有用信息的可能性更大。不仅如此,那些提供的解决方案中被选出的最精准的答案也会被写入到官方文档中。 + +### Ubuntu 的未来 + +我认为 Ubuntu 的 Unity 界面(LCTT 译注:Unity 是 Canonical 公司为 Ubuntu 操作系统的 GNOME 桌面环境开发的图形化界面)在提升桌面占有率上少有作为。我能理解其中的缘由,现在它主要做一些诸如可以使开发团队的工作更轻松的事情。但是最终,我还是认为 Unity 为 Ubuntu MATE 和 Linux Mint 的普及铺平道路。 + +我最好奇的一点是 Ubuntu's IRC 和邮件列表的发展(LCTT 译注:可以在 Ubuntu LoCo Teams 的 IRC Chat 上提问关于地方团队和计划的事件的问题,也可以和一些不同团队的成员进行交流)。事实是,他们都不能像 Ubuntu 问答板块那样文档化。至于邮件列表,我一直认为这对于合作是一种很痛苦的过时方法,但这仅仅是我的个人看法——其他人可能有不同的看法,也可能会认为它很好。 + +你怎么看?你认为 Ubuntu 将来会占据主要的份额吗?也许你会认为 Arch 和 Linux Mint 或者其他的发行版会在普及度上打败 Ubuntu? 既然这样,那请大声说出你最喜爱的发行版。如果这个发行版是 Ubuntu 衍生版 ,说说你为什么更喜欢它而不是 Ubuntu 本身。如果不出意外,Ubuntu 会成为构建其他发行版的基础,我想很多人都是这样认为的。 + +-------------------------------------------------------------------------------- + +via: http://www.datamation.com/open-source/why-ubuntu-based-distros-are-leaders.html + +作者:[Matt Hartley][a] +译者:[vim-kakali](https://github.com/vim-kakali) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.datamation.com/author/Matt-Hartley-3080.html +[1]: http://www.ubuntu.com/ +[2]: https://www.debian.org/ +[3]: http://www.datamation.com/open-source/ubuntu-snap-packages-the-good-the-bad-the-ugly.html +[4]: http://loco.ubuntu.com/ +[5]: http://askubuntu.com/ diff --git a/translated/talk/20151023 Mark Shuttleworth--The Man Behind Ubuntu Operating System.md b/published/201606/20151023 Mark Shuttleworth--The Man Behind Ubuntu Operating System.md similarity index 80% rename from translated/talk/20151023 Mark Shuttleworth--The Man Behind Ubuntu Operating System.md rename to published/201606/20151023 Mark Shuttleworth--The Man Behind Ubuntu Operating System.md index b40048201b..b5923ca86a 100644 --- a/translated/talk/20151023 Mark Shuttleworth--The Man Behind Ubuntu Operating System.md +++ b/published/201606/20151023 Mark Shuttleworth--The Man Behind Ubuntu Operating System.md @@ -3,21 +3,21 @@ ![](http://www.unixmen.com/wp-content/uploads/2015/10/Mark-Shuttleworth-652x445.jpg) -**马克·理查德·沙特尔沃思(马克Richard Shuttleworth)** 是 Ubuntu 的创始人,也被称作 [Debian 背后的人][1]([之一][2])。他于 1973 年出生在南非的韦尔科姆(Welkom)。他不仅是个企业家,还是个太空游客——他是第一个前往太空旅行的非洲独立国家的公民。 +**马克·理查德·沙特尔沃思(Mark Richard Shuttleworth)** 是 Ubuntu 的创始人,也被称作 [Debian 背后的人][1]([之一][2])。他于 1973 年出生在南非的韦尔科姆(Welkom)。他不仅是个企业家,还是个太空游客——他是第一个前往太空旅行的非洲独立国家的公民。 马克曾在 1996 年成立了一家名为 **Thawte** 的互联网商务安全公司,那时他还在开普敦大学( University of Cape Town)的学习金融和信息技术。 -2000 年,马克创立了 HBD(Here be Dragons (此处有龙/危险)的缩写,所以其吉祥物是一只龙),这是一家投资公司,同时他还创立了沙特尔沃思基金会(Shuttleworth Foundation),致力于给社会中有创新性的领袖以奖金和投资等形式提供资助。 +2000 年,马克创立了 HBD(Here be Dragons (此处有龙/危险)的缩写,所以其吉祥物是一只龙),这是一家投资公司,同时他还创立了沙特尔沃思基金会(Shuttleworth Foundation),致力于以奖金和投资等形式给社会中有创新性的领袖提供资助。 -> "移动设备对于个人电脑行业的未来而言至关重要。比如就在这个月,相对于平板电脑的发展而言,传统 PC 行业很明显正在萎缩。所以如果我们想要涉足个人电脑产业,我们必须首先涉足移动行业。移动产业之所以有趣,是因为在这里没有盗版 Windows 操作系统的市场。所以如果你为你的操作系统赢得了一台设备的市场份额,这台设备会一直使用你的操作系统。在传统 PC 行业,我们时不时得和“免费”的 Windows 产生竞争,这是一种非常微妙的挑战。所以我们现在的重心是围绕 Ubuntu 和移动设备——手机和平板——以图与普通用户建立更深层次的联系。" +> “移动设备对于个人电脑行业的未来而言至关重要。比如就在这个月,相对于平板电脑的发展而言,传统 PC 行业很明显正在萎缩。所以如果我们想要涉足个人电脑产业,我们必须首先涉足移动行业。移动产业之所以有趣,是因为在这里没有盗版 Windows 操作系统的市场。所以如果你为你的操作系统赢得了一台设备的市场份额,这台设备会一直使用你的操作系统。在传统 PC 行业,我们时不时得和“免费”的 Windows 产生竞争,这是一种非常微妙的挑战。所以我们现在的重心是围绕 Ubuntu 和移动设备——手机和平板——以图与普通用户建立更深层次的联系。” > > — 马克·沙特尔沃思 2002 年,他在俄罗斯的星城(Star City)接受了为期一年的训练,随后作为联盟号 TM-34 任务组的一员飞往了国际空间站。再后来,在面向有志于航空航天或者其相关学科的南非学生群体发起了推广科学、编程及数学的运动后,马克 创立了 **Canonical Ltd**。此后直至2013年,他一直在领导 Ubuntu 操作系统的开发。 -现今,Shuttleworth 拥有英国与南非双重国籍并和 18 只可爱的鸭子住在英国的 Isle of Man 小岛上的一处花园,一同的还有他可爱的女友 Claire,两条黑色母狗以及时不时经过的羊群。 +现今,沙特尔沃思拥有英国与南非双重国籍并和 18 只可爱的鸭子住在英国的 Isle of Man 小岛上的一处花园,一同的还有他可爱的女友 Claire,两条黑色母狗以及时不时经过的羊群。 -> "电脑不仅仅是一台电子设备了。它现在是你思维的延续,以及通向他人的大门。" +> “电脑不仅仅是一台电子设备了。它现在是你思维的延续,以及通向他人的大门。” > > — 马克·沙特尔沃思 @@ -41,7 +41,7 @@ > > — 马克·沙特尔沃思 -### Linux、免费开源软件与马克·沙特尔沃思 ### +### Linux、自由开源软件与马克·沙特尔沃思 ### 在 90 年代后期,马克曾作为一名开发者参与 Debian 操作系统项目。 @@ -49,7 +49,7 @@ 2004 年,马克通过出资开发基于 Debian 的 Ubuntu 操作系统返回了自由软件界,这一切也经由他的 Canonical 公司完成。 -2005 年,马克出资建立了 Ubuntu 基金会并投入了一千万美元作为启动资金。在 Ubuntu 项目内,马克经常被一个朗朗上口的名字称呼——“**SABDFL :自封的生命之仁慈独裁者(Self-Appointed Benevolent Dictator for Life)**”。为了能够找到足够多的高手开发这个巨大的项目,马克花费了 6 个月的时间从 Debian 邮件列表里寻找,这一切都是在他乘坐在南极洲的一艘破冰船——赫列布尼科夫船长号(Kapitan Khlebnikov)——上完成的。同年,马克买下了 Impi Linux 65% 的股份。 +2005 年,马克出资建立了 Ubuntu 基金会并投入了一千万美元作为启动资金。在 Ubuntu 项目内,人们经常用一个朗朗上口的名字称呼他——“**SABDFL :自封的生命之仁慈独裁者(Self-Appointed Benevolent Dictator for Life)**”。为了能够找到足够多的高手开发这个巨大的项目,马克花费了 6 个月的时间从 Debian 邮件列表里寻找,这一切都是在他乘坐在南极洲的一艘破冰船——赫列布尼科夫船长号(Kapitan Khlebnikov)——上完成的。同年,马克买下了 Impi Linux 65% 的股份。 > “我呼吁电信公司的掌权者们尽快开发出跨洲际的高效信息传输服务。” @@ -78,7 +78,7 @@ ![](http://www.unixmen.com/wp-content/uploads/2015/10/Mark-Shuttleworth1.jpg) -在太空中,马克与纳尔逊·曼德拉(Nelson Mandela)和另一个 14 岁的南非女孩米歇尔·福斯特(Michelle Foster) (她问马克要不要娶她)通过无线电进行了交谈。马克礼貌地回避了这个结婚问题,在巧妙地改换话题之前他说他感到很荣幸。身患绝症的女孩福斯特通过梦想基金会( Dream foundation)的赞助获得了与马克和纳尔逊·曼德拉交谈的机会。 +在太空中,马克与纳尔逊·曼德拉(Nelson Mandela)和另一个 14 岁的南非女孩米歇尔·福斯特(Michelle Foster) (她问马克要不要娶她)通过无线电进行了交谈。马克礼貌地回避了这个结婚问题,但在巧妙地改换话题之前他说他感到很荣幸。身患绝症的女孩福斯特通过梦想基金会( Dream foundation)的赞助获得了与马克和纳尔逊·曼德拉交谈的机会。 归来后,马克在世界各地做了旅行,并和各地的学生就太空之旅发表了感言。 diff --git a/published/20151210 Getting started with Docker by Dockerizing this Blog.md.md b/published/201606/20151210 Getting started with Docker by Dockerizing this Blog.md.md similarity index 100% rename from published/20151210 Getting started with Docker by Dockerizing this Blog.md.md rename to published/201606/20151210 Getting started with Docker by Dockerizing this Blog.md.md diff --git a/published/20160214 How to Install MariaDB 10 on CentOS 7 CPanel Server.md b/published/201606/20160214 How to Install MariaDB 10 on CentOS 7 CPanel Server.md similarity index 100% rename from published/20160214 How to Install MariaDB 10 on CentOS 7 CPanel Server.md rename to published/201606/20160214 How to Install MariaDB 10 on CentOS 7 CPanel Server.md diff --git a/published/20160217 How to Enable Multiple PHP-FPM Instances with Nginx or Apache.md b/published/201606/20160217 How to Enable Multiple PHP-FPM Instances with Nginx or Apache.md similarity index 100% rename from published/20160217 How to Enable Multiple PHP-FPM Instances with Nginx or Apache.md rename to published/201606/20160217 How to Enable Multiple PHP-FPM Instances with Nginx or Apache.md diff --git a/published/20160218 7 Steps to Start Your Linux SysAdmin Career.md b/published/201606/20160218 7 Steps to Start Your Linux SysAdmin Career.md similarity index 100% rename from published/20160218 7 Steps to Start Your Linux SysAdmin Career.md rename to published/201606/20160218 7 Steps to Start Your Linux SysAdmin Career.md diff --git a/published/20160218 9 Key Trends in Hybrid Cloud Computing.md b/published/201606/20160218 9 Key Trends in Hybrid Cloud Computing.md similarity index 100% rename from published/20160218 9 Key Trends in Hybrid Cloud Computing.md rename to published/201606/20160218 9 Key Trends in Hybrid Cloud Computing.md diff --git a/published/20160218 A Linux-powered microwave oven.md b/published/201606/20160218 A Linux-powered microwave oven.md similarity index 100% rename from published/20160218 A Linux-powered microwave oven.md rename to published/201606/20160218 A Linux-powered microwave oven.md diff --git a/published/20160218 Getting to Know Linux File Permissions.md b/published/201606/20160218 Getting to Know Linux File Permissions.md similarity index 100% rename from published/20160218 Getting to Know Linux File Permissions.md rename to published/201606/20160218 Getting to Know Linux File Permissions.md diff --git a/published/20160218 Linux Systems Patched for Critical glibc Flaw.md b/published/201606/20160218 Linux Systems Patched for Critical glibc Flaw.md similarity index 100% rename from published/20160218 Linux Systems Patched for Critical glibc Flaw.md rename to published/201606/20160218 Linux Systems Patched for Critical glibc Flaw.md diff --git a/published/20160218 Top 4 open source issue tracking tools.md b/published/201606/20160218 Top 4 open source issue tracking tools.md similarity index 100% rename from published/20160218 Top 4 open source issue tracking tools.md rename to published/201606/20160218 Top 4 open source issue tracking tools.md diff --git a/published/20160221 NXP unveils a tiny 64-bit ARM processor for the Internet of Things.md b/published/201606/20160221 NXP unveils a tiny 64-bit ARM processor for the Internet of Things.md similarity index 100% rename from published/20160221 NXP unveils a tiny 64-bit ARM processor for the Internet of Things.md rename to published/201606/20160221 NXP unveils a tiny 64-bit ARM processor for the Internet of Things.md diff --git a/published/20160223 New Docker Data Center Admin Suite Should Bring Order to Containerization.md b/published/201606/20160223 New Docker Data Center Admin Suite Should Bring Order to Containerization.md similarity index 100% rename from published/20160223 New Docker Data Center Admin Suite Should Bring Order to Containerization.md rename to published/201606/20160223 New Docker Data Center Admin Suite Should Bring Order to Containerization.md diff --git a/published/20160228 Two Outstanding All-in-One Linux Servers.md b/published/201606/20160228 Two Outstanding All-in-One Linux Servers.md similarity index 100% rename from published/20160228 Two Outstanding All-in-One Linux Servers.md rename to published/201606/20160228 Two Outstanding All-in-One Linux Servers.md diff --git a/published/20160304 Image processing at NASA with open source tools.md b/published/201606/20160304 Image processing at NASA with open source tools.md similarity index 100% rename from published/20160304 Image processing at NASA with open source tools.md rename to published/201606/20160304 Image processing at NASA with open source tools.md diff --git a/published/20160510 65% of companies are contributing to open source projects.md b/published/201606/20160510 65% of companies are contributing to open source projects.md similarity index 100% rename from published/20160510 65% of companies are contributing to open source projects.md rename to published/201606/20160510 65% of companies are contributing to open source projects.md diff --git a/published/20160513 How to Set Up 2-Factor Authentication for Login and sudo.md b/published/201606/20160513 How to Set Up 2-Factor Authentication for Login and sudo.md similarity index 100% rename from published/20160513 How to Set Up 2-Factor Authentication for Login and sudo.md rename to published/201606/20160513 How to Set Up 2-Factor Authentication for Login and sudo.md diff --git a/published/20160514 NODEOS - LINUX DISTRIBUTION FOR NODE LOVERS.md b/published/201606/20160514 NODEOS - LINUX DISTRIBUTION FOR NODE LOVERS.md similarity index 100% rename from published/20160514 NODEOS - LINUX DISTRIBUTION FOR NODE LOVERS.md rename to published/201606/20160514 NODEOS - LINUX DISTRIBUTION FOR NODE LOVERS.md diff --git a/published/20160516 4 BEST MODERN OPEN SOURCE CODE EDITORS FOR LINUX.md b/published/201606/20160516 4 BEST MODERN OPEN SOURCE CODE EDITORS FOR LINUX.md similarity index 100% rename from published/20160516 4 BEST MODERN OPEN SOURCE CODE EDITORS FOR LINUX.md rename to published/201606/20160516 4 BEST MODERN OPEN SOURCE CODE EDITORS FOR LINUX.md diff --git a/published/20160518 Android Use Apps Even Without Installing Them.md b/published/201606/20160518 Android Use Apps Even Without Installing Them.md similarity index 100% rename from published/20160518 Android Use Apps Even Without Installing Them.md rename to published/201606/20160518 Android Use Apps Even Without Installing Them.md diff --git a/published/20160520 ORB - NEW GENERATION OF LINUX APPS ARE HERE.md b/published/201606/20160520 ORB - NEW GENERATION OF LINUX APPS ARE HERE.md similarity index 100% rename from published/20160520 ORB - NEW GENERATION OF LINUX APPS ARE HERE.md rename to published/201606/20160520 ORB - NEW GENERATION OF LINUX APPS ARE HERE.md diff --git a/published/201606/20160523 Driving cars into the future with Linux.md b/published/201606/20160523 Driving cars into the future with Linux.md new file mode 100644 index 0000000000..fad7ca99f2 --- /dev/null +++ b/published/201606/20160523 Driving cars into the future with Linux.md @@ -0,0 +1,106 @@ +与 Linux 一同驾车奔向未来 +=========================================== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/open-snow-car-osdc-lead.png?itok=IgYZ6mNY) + +当我驾车的时候并没有这么想过,但是我肯定喜欢一个配有这样系统的车子,它可以让我按下几个按钮就能与我的妻子、母亲以及孩子们语音通话。这样的系统也可以让我选择是否从云端、卫星广播、以及更传统的 AM/FM 收音机收听音乐流媒体。我也会得到最新的天气情况,以及它可以引导我的车载 GPS 找到抵达下一个目的地的最快路线。[车载娱乐系统(In-vehicle infotainment)][1],业界常称作 IVI,它已经普及出现在最新的汽车上了。 + +前段时间,我乘坐飞机跨越了数百英里,然后租了一辆汽车。令人愉快的是,我发现我租赁的汽车上配置了类似我自己车上同样的 IVI 技术。毫不犹豫地,我就通过蓝牙连接把我的联系人上传到了系统当中,然后打电话回家给我的家人,让他们知道我已经安全抵达了,然后我的主机会让他们知道我正在去往他们家的路上。 + +在最近的[新闻综述][2]中,Scott Nesbitt 引述了一篇文章,说福特汽车公司因其开源的[智能设备连接(Smart Device Link)][3](SDL)从竞争对手汽车制造商中得到了足够多的回报,这个中间件框架可以用于支持移动电话。 SDL 是 [GENIVI 联盟][4]的一个项目,这个联盟是一个非营利性组织,致力于建设支持开源车载娱乐系统的中间件。据 GENIVI 的执行董事 [Steven Crumb][5] 称,他们的[成员][6]有很多,包括戴姆勒集团、现代、沃尔沃、日产、本田等等 170 个企业。 + +为了在同行业间保持竞争力,汽车生产企业需要一个中间设备系统,以支持现代消费者所使用的各种人机界面技术。无论您使用的是 Android、iOS 还是其他设备,汽车 OEM 厂商都希望自己的产品能够支持这些。此外,这些的 IVI 系统必须有足够适应能力以支持日益变化的移动技术。OEM 厂商希望提供有价值的服务,并可以在他们的 IVI 之上增加服务,以满足他们客户的各种需求。 + +### 步入 Linux 和开源软件 + +除了 GENIVI 在努力之外,[Linux 基金会][7]也赞助支持了[车载 Linux(Automotive Grade Linux)][8](AGL)工作组,这是一个致力于为汽车应用寻求开源解决方案的软件基金会。虽然 AGL 初期将侧重于 IVI 系统,但是未来他们希望发展到不同的方向,包括[远程信息处理(telematics)][9]、抬头显示器(HUD)及其他控制系统等等。 现在 AGL 已经有超过 50 名成员,包括捷豹、丰田、日产,并在其[最近发布的一篇公告][10]中宣称福特、马自达、三菱、和斯巴鲁也加入了。 + +为了了解更多信息,我们采访了这一新兴领域的两位领导人。具体来说,我们想知道 Linux 和开源软件是如何被使用的,并且它们是如何事实上改变了汽车行业的面貌。首先,我们将与 [Alison Chaiken][11] 谈谈,她是一位任职于 Peloton Technology 的软件工程师,也是一位在车载 Linux 、网络安全和信息透明化方面的专家。她曾任职于 [Alison Chaiken][11] 公司、诺基亚和斯坦福直线性加速器。然后我们和 [Steven Crumb][12] 进行了交谈,他是 GENIVI 执行董事,他之前从事于高性能计算环境(超级计算机和早期的云计算)的开源工作。他说,虽然他再不是一个程序员了,但是他乐于帮助企业解决在使用开源软件时的实际业务问题。 + +### 采访 Alison Chaiken (by [Deb Nicholson][13]) + +#### 你是如何开始对汽车软件领域感兴趣的? + +我曾在诺基亚从事于手机上的 [MeeGo][14] 产品,2009 年该项目被取消了。我想,我下一步怎么办?其时,我的一位同事正在从事于 [MeeGo-IVI][15],这是一个早期的车载 Linux 发行版。 “Linux 在汽车方面将有很大发展,” 我想,所以我就朝着这个方向努力。 + +#### 你能告诉我们你在这些日子里工作在哪些方面吗? + +我目前正在启动一个高级巡航控制系统的项目,它用在大型卡车上,使用实时 Linux 以提升安全性和燃油经济性。我喜欢在这方面的工作,因为没有人会反对提升货运的能力。 + +#### 近几年有几则汽车被黑的消息。开源代码方案可以帮助解决这个问题吗? + +我恰好针对这一话题准备了一次讲演,我会在南加州 Linux 2016 博览会上就 Linux 能否解决汽车上的安全问题做个讲演 ([讲演稿在此][16])。值得注意的是,GENIVI 和车载 Linux 项目已经公开了他们的代码,这两个项目可以通过 Git 提交补丁。(如果你有补丁的话),请给上游发送您的补丁!许多眼睛都盯着,bug 将无从遁形。 + +#### 执法机构和保险公司可以找到很多汽车上的数据的用途。他们获取这些信息很容易吗? + +好问题。IEEE-1609 专用短程通信标准(Dedicated Short Range Communication Standard)就是为了让汽车的 WiFi 消息可以安全、匿名地传递。不过,如果你从你的车上发推,那可能就有人能够跟踪到你。 + +#### 开发人员和公民个人可以做些什么,以在汽车技术进步的同时确保公民自由得到保护? + +电子前沿基金会( Electronic Frontier Foundation)(EFF)在关注汽车问题方面做了出色的工作,包括对哪些数据可以存储在汽车 “黑盒子”里通过官方渠道发表了看法,以及 DMCA 规定 1201 如何应用于汽车上。 + +#### 在未来几年,你觉得在汽车方面会发生哪些令人激动的发展? + +可以拯救生命的自适应巡航控制系统和防撞系统将取得长足发展。当它们大量进入汽车里面时,我相信这会使得(因车祸而导致的)死亡人数下降。如果这都不令人激动,我不知道还有什么会更令人激动。此外,像自动化停车辅助功能,将会使汽车更容易驾驶,减少汽车磕碰事故。 + +#### 我们需要做什么?人们怎样才能参与? + +车载 Linux 开发是以开源的方式开发,它运行在每个人都能买得起的廉价硬件上(如树莓派 2 和中等价位的 Renesas Porter 主板)。 GENIVI 汽车 Linux 中间件联盟通过 Git 开源了很多软件。此外,还有很酷的 [OSVehicle 开源硬件][17]汽车平台。 + +只需要不太多的预算,人们就可以参与到 Linux 软件和开放硬件中。如果您感兴趣,请加入我们在 Freenode 上的IRC #automotive 吧。 + +### 采访 Steven Crumb (by Don Watkins) + +#### GENIVI 在 IVI 方面做了哪些巨大贡献? + +GENIVI 率先通过使用自由开源软件填补了汽车行业的巨大空白,这包括 Linux、非安全关键性汽车软件(如车载娱乐系统(IVI))等。作为消费者,他们很期望在车辆上有和智能手机一样的功能,对这种支持 IVI 功能的软件的需求量成倍地增长。不过不断提升的软件数量也增加了建设 IVI 系统的成本,从而延缓了其上市时间。 + +GENIVI 使用开源软件和社区开发的模式为汽车制造商及其软件提供商节省了大量资金,从而显著地缩短了产品面市时间。我为 GENIVI 而感到激动,我们有幸引导了一场革命,在缓慢进步的汽车行业中,从高度结构化和专有的解决方案转换为以社区为基础的开发方式。我们还没有完全达成目标,但是我们很荣幸在这个可以带来实实在在好处的转型中成为其中的一份子。 + +#### 你们的主要成员怎样推动了 GENIVI 的发展方向? + +GENIVI 有很多成员和非成员致力于我们的工作。在许多开源项目中,任何公司都可以通过通过技术输出而发挥影响,包括简单地贡献代码、补丁、花点时间测试。前面说过,宝马、奔驰、现代汽车、捷豹路虎、标致雪铁龙、雷诺/日产和沃尔沃都是 GENIVI 积极的参与者和贡献者,其他的许多 OEM 厂商也在他们的汽车中采用了 IVI 解决方案,广泛地使用了 GENIVI 的软件。 + +#### 这些贡献的代码使用了什么许可证? + +GENIVI 采用了一些许可证,包括从(L)GPLv2 到 MPLv2 和 Apache2.0。我们的一些工具使用的是 Eclipse 许可证。我们有一个[公开许可策略][18],详细地说明了我们的许可证偏好。 + +#### 个人或团体如何参与其中?社区的参与对于这个项目迈向成功有多重要? + +GENIVI 的开发完全是开放的([projects.genivi.org][19]),因此,欢迎任何有兴趣在汽车中使用开源软件的人参加。也就是说,公司可以通过成员的方式[加入该联盟][20],联盟以开放的方式资助其不断进行开发。GENIVI 的成员可以享受各种各样的便利,在过去六年中,已经有多达 140 家公司参与到这个全球性的社区当中。 + +社区对于 GENIVI 是非常重要的,没有一个活跃的贡献者社区,我们不可能在这些年开发和维护了这么多有价值的软件。我们努力让参与到 GENIVI 更加简单,现在只要加入一个[邮件列表][21]就可以接触到各种软件项目中的人们。我们使用了许多开源项目采用的标准做法,并提供了高品质的工具和基础设施,以帮助开发人员宾至如归而富有成效。 + +无论你是否熟悉汽车软件,都欢迎你加入我们的社区。人们已经对汽车改装了许多年,所以对于许多人来说,在汽车上修修改改是自热而然的做法。对于汽车来说,软件是一个新的领域,GENIVI 希望能为对汽车和开源软件有兴趣的人打开这扇门。 + +------------------------------- +via: https://opensource.com/business/16/5/interview-alison-chaiken-steven-crumb + +作者:[Don Watkins][a] +译者:[erlinux](https://github.com/erlinux) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[1]: https://en.wikipedia.org/wiki/In_car_entertainment +[2]: https://opensource.com/life/16/1/weekly-news-jan-9 +[3]: http://projects.genivi.org/smartdevicelink/home +[4]: http://www.genivi.org/ +[5]: https://www.linkedin.com/in/stevecrumb +[6]: http://www.genivi.org/genivi-members +[7]: http://www.linuxfoundation.org/ +[8]: https://www.automotivelinux.org/ +[9]: https://en.wikipedia.org/wiki/Telematics +[10]: https://www.automotivelinux.org/news/announcement/2016/01/ford-mazda-mitsubishi-motors-and-subaru-join-linux-foundation-and +[11]: https://www.linkedin.com/in/alison-chaiken-3ba456b3 +[12]: https://www.linkedin.com/in/stevecrumb +[13]: https://opensource.com/users/eximious +[14]: https://en.wikipedia.org/wiki/MeeGo +[15]: http://webinos.org/deliverable-d026-target-platform-requirements-and-ipr/automotive/ +[16]: http://she-devel.com/Chaiken_automotive_cybersecurity.pdf +[17]: https://www.osvehicle.com/ +[18]: http://projects.genivi.org/how +[19]: http://projects.genivi.org/ +[20]: http://genivi.org/join +[21]: http://lists.genivi.org/mailman/listinfo/genivi-projects diff --git a/published/20160524 Test Fedora 24 Beta in an OpenStack cloud.md b/published/201606/20160524 Test Fedora 24 Beta in an OpenStack cloud.md similarity index 100% rename from published/20160524 Test Fedora 24 Beta in an OpenStack cloud.md rename to published/201606/20160524 Test Fedora 24 Beta in an OpenStack cloud.md diff --git a/published/20160526 BEST LINUX PHOTO MANAGEMENT SOFTWARE IN 2016.md b/published/201606/20160526 BEST LINUX PHOTO MANAGEMENT SOFTWARE IN 2016.md similarity index 100% rename from published/20160526 BEST LINUX PHOTO MANAGEMENT SOFTWARE IN 2016.md rename to published/201606/20160526 BEST LINUX PHOTO MANAGEMENT SOFTWARE IN 2016.md diff --git a/published/20160529 LAMP Stack Installation Guide on Ubuntu Server 16.04 LTS.md b/published/201606/20160529 LAMP Stack Installation Guide on Ubuntu Server 16.04 LTS.md similarity index 100% rename from published/20160529 LAMP Stack Installation Guide on Ubuntu Server 16.04 LTS.md rename to published/201606/20160529 LAMP Stack Installation Guide on Ubuntu Server 16.04 LTS.md diff --git a/published/20160601 Apps to Snaps.md b/published/201606/20160601 Apps to Snaps.md similarity index 100% rename from published/20160601 Apps to Snaps.md rename to published/201606/20160601 Apps to Snaps.md diff --git a/published/20160601 scp command in Linux.md b/published/201606/20160601 scp command in Linux.md similarity index 100% rename from published/20160601 scp command in Linux.md rename to published/201606/20160601 scp command in Linux.md diff --git a/published/20160605 How to Add Cron Jobs in Linux and Unix.md b/published/201606/20160605 How to Add Cron Jobs in Linux and Unix.md similarity index 100% rename from published/20160605 How to Add Cron Jobs in Linux and Unix.md rename to published/201606/20160605 How to Add Cron Jobs in Linux and Unix.md diff --git a/published/20160605 Will Google Replace Passwords With A New Trust-Based Authentication Method.md b/published/201606/20160605 Will Google Replace Passwords With A New Trust-Based Authentication Method.md similarity index 100% rename from published/20160605 Will Google Replace Passwords With A New Trust-Based Authentication Method.md rename to published/201606/20160605 Will Google Replace Passwords With A New Trust-Based Authentication Method.md diff --git a/published/20160611 vlock – A Smart Way to Lock User Virtual Console or Terminal in Linux.md b/published/201606/20160611 vlock – A Smart Way to Lock User Virtual Console or Terminal in Linux.md similarity index 100% rename from published/20160611 vlock – A Smart Way to Lock User Virtual Console or Terminal in Linux.md rename to published/201606/20160611 vlock – A Smart Way to Lock User Virtual Console or Terminal in Linux.md diff --git a/translated/tech/20160621 Building Serverless App with Docker.md b/published/201606/20160621 Building Serverless App with Docker.md similarity index 81% rename from translated/tech/20160621 Building Serverless App with Docker.md rename to published/201606/20160621 Building Serverless App with Docker.md index 9af6c5d7aa..0b5409fc89 100644 --- a/translated/tech/20160621 Building Serverless App with Docker.md +++ b/published/201606/20160621 Building Serverless App with Docker.md @@ -1,9 +1,9 @@ -用 docker 创建 serverless 应用 +用 Docker 创建 serverless 应用 ====================================== -当今世界会时不时地出现一波科技浪潮,将以前的技术拍死在海滩上。针对 serverless 应用的概念我们已经谈了很多,它是指将你的应用程序按功能来部署,这些功能在被用到时才会启动。你不用费心去管理服务器和程序规模,因为它们会在需要的时候在一个集群中启动并运行。 +当今世界会时不时地出现一波波科技浪潮,将以前的技术拍死在海滩上。针对 serverless 应用的概念我们已经谈了很多,它是指将你的应用程序按功能来部署,这些功能在被用到时才会启动。你不用费心去管理服务器和程序规模,因为它们会在需要的时候在一个集群中启动并运行。 -但是 serverless 并不意味着没有 Docker 什么事儿,事实上 Docker 就是 serverless 的。你可以使用 Docker 来容器化这些功能,然后在 Swarm 中按需求来运行它们。Serverless 是一项构建分布式应用的技术,而 Docker 是它们完美的构建平台。 +但是 serverless 并不意味着没有 Docker 什么事儿,事实上 Docker 就是 serverless 的。你可以使用 Docker 来容器化这些功能,然后在 Swarm 中按需求来运行它们。serverless 是一项构建分布式应用的技术,而 Docker 是它们完美的构建平台。 ### 从 servers 到 serverless @@ -28,13 +28,13 @@ client.run("bfirsh/serverless-record-vote-task", [voter_id, vote], detach=True) 这个投票处理进程和消息队列可以用运行在 Swarm 上的 Docker 容器来代替,并实现按需自动部署。 -我们也可以用容器替换 web 前端,使用一个轻量级 HTTP 服务器来触发容器响应一个 HTTP 请求。Docker 容器代替长期运行的 HTTP 服务器来挑起响应请求的重担,这些容器可以自动扩容来支撑大访问量。 +我们也可以用容器替换 web 前端,使用一个轻量级 HTTP 服务器来触发容器响应一个 HTTP 请求。Docker 容器代替长期运行的 HTTP 服务器来挑起响应请求的重担,这些容器可以自动扩容来支撑更大访问量。 新的架构就像这样: ![](https://blog.docker.com/wp-content/uploads/Picture2.png) -红色框内是持续运行的服务,绿色框内是按需启动的容器。这个架构提供更少的长期运行服务让你管理,并且可以自动扩容(最大容量由你的 Swarm 决定)。 +红色框内是持续运行的服务,绿色框内是按需启动的容器。这个架构里需要你来管理的长期运行服务更少,并且可以自动扩容(最大容量由你的 Swarm 决定)。 ### 我们可以做点什么? @@ -51,11 +51,11 @@ client.run("bfirsh/serverless-record-vote-task", [voter_id, vote], detach=True) ### 下一步怎么做 -我们提供了这些前卫的工具和概念来构建应用,并没有深入发掘它们的功能。我们的架构里还是存在长期运行的服务,将来我们需要使用 Swarm 来把所有服务都用按需扩容的方式实现 +我们提供了这些前卫的工具和概念来构建应用,并没有深入发掘它们的功能。我们的架构里还是存在长期运行的服务,将来我们需要使用 Swarm 来把所有服务都用按需扩容的方式实现。 希望本文能在你搭建架构时给你一些启发,但我们还是需要你的帮助。我们提供了所有的基本工具,但它们还不是很完善,我们需要更多更好的工具、库、应用案例、文档以及其他资料。 -[我们在这里发布了工具、库和文档][3]。如果想了解更多,请移步到那里,另外请贡献一些链接给我们,这样我们就能一直工作了。 +[我们在这里发布了工具、库和文档][3]。如果想了解更多,请贡献给我们一些你知道的资源,以便我们能够完善这篇文章。 玩得愉快。 @@ -77,7 +77,7 @@ via: https://blog.docker.com/2016/06/building-serverless-apps-with-docker/ 作者:[Ben Firshman][a] 译者:[bazz2](https://github.com/bazz2) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/talk/20160624 IT runs on the cloud and the cloud runs on Linux. Any questions.md b/sources/talk/20160624 IT runs on the cloud and the cloud runs on Linux. Any questions.md index 2a575c1a31..94f0a8af2f 100644 --- a/sources/talk/20160624 IT runs on the cloud and the cloud runs on Linux. Any questions.md +++ b/sources/talk/20160624 IT runs on the cloud and the cloud runs on Linux. Any questions.md @@ -1,3 +1,4 @@ +chenxinlong translating IT runs on the cloud, and the cloud runs on Linux. Any questions? =================================================================== @@ -37,7 +38,7 @@ So, just as the vast majority of Android phone and Chromebook users have no clue via: http://www.zdnet.com/article/it-runs-on-the-cloud-and-the-cloud-runs-on-linux-any-questions/#ftag=RSSbaffb68 作者:[Steven J. Vaughan-Nichols][a] -译者:[译者ID](https://github.com/译者ID) +译者:[chenxinlong](https://github.com/chenxinlong) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20160218 What do Linux developers think of Git and GitHub.md b/sources/tech/20160218 What do Linux developers think of Git and GitHub.md deleted file mode 100644 index c0de7f4e6a..0000000000 --- a/sources/tech/20160218 What do Linux developers think of Git and GitHub.md +++ /dev/null @@ -1,95 +0,0 @@ -translated by mudongliang - -What do Linux developers think of Git and GitHub? -===================================================== - -**Also in today’s open source roundup: DistroWatch reviews XStream Desktop 153, and Street Fighter V is coming to Linux and SteamOS in the spring** - -## What do Linux developers think of Git and GitHub? - -The popularity of Git and GitHub among Linux developers is well established. But what do developers think of them? And should GitHub really be synonymous with Git itself? A Linux redditor recently asked about this and got some very interesting answers. - -Dontwakemeup46 asked his question: - ->I am learning Git and Github. What I am interested in is how these two are viewed by the community. That git and github are used extensively, is something I know. But are there serious issues with either Git or Github? Something that the community would love to change? - -[More at Reddit](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580413015211&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=https%3A%2F%2Fwww.reddit.com%2Fr%2Flinux%2Fcomments%2F45jy59%2Fthe_popularity_of_git_and_github%2F&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=More%20at%20Reddit) - -His fellow Linux redditors responded with their thoughts about Git and GitHub: - ->Derenir: ”Github is not affliated with Git. - ->Git is made by Linus Torvalds. - ->Github hardly supports Linux. - ->Github is a corporate bordelo that tries to make money from Git. - ->[https://desktop.github.com/](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580415025712&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&type=U&out=https%3A%2F%2Fdesktop.github.com%2F&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=https%3A%2F%2Fdesktop.github.com%2F) see here no Linux Support.” - ->**Bilog78**: ”A minor update: git hasn't been “made by Linus Torvalds” for a while. The maintainer is Junio C Hamano and the main contributors after him are Jeff King and Shawn O. Pearce.” - ->**Fearthefuture**: ”I like git but can't understand why people even use github anymore. From my point of view the only thing it does better than bitbucket are user statistics and the larger userbase. Bitbucket has unlimited free private repos, much better UI and very good integration with other services such as Jenkins.” - ->**Thunger**: ”Gitlab.com is also nice, especially since you can host your own instance on your own servers.” - ->**Takluyver**: ”Lots of people are familiar with the UI of Github and associated services like Travis, and lots of people already have Github accounts, so it's a good place for projects to be. People also use their Github profile as a kind of portfolio, so they're motivated to put more projects on there. Github is a de facto standard for hosting open source projects.” - ->**Tdammers**: ”Serious issue with git would be the UI, which is kind of counterintuitive, to the point that many users just stick with a handful of memorized incantations. - -Github: most serious issue here is that it's a proprietary hosted solution; you buy convenience, and the price is that your code is on someone else's server and not under your control anymore. Another common criticism of github is that its workflow isn't in line with the spirit of git itself, particularly the way pull requests work. And finally, github is monopolizing the code hosting landscape, and that's bad for diversity, which in turn is crucial for a thriving free software community.” - ->**Dies**: ”How is that the case? More importantly, if that is the case, then what's done is done and I guess we're stuck with Github since they control so many projects.” - ->**Tdammers**: ”The code is hosted on someone else's server, "someone else" in this case being github. Which, for an open-source project, is not typically a huge problem, but still, you don't control it. If you have a private project on github, then the only assurance you have that it will remain private is github's word for it. If you decide to delete things, then you can never be sure whether it's been deleted, or just hidden. - -Github doesn't control the projects themselves (you can always take your code and host it elsewhere, declaring the new location the "official" one), it just has deeper access to the code than the developers themselves.” - ->**Drelos**: ”I have read a lot of praises and bad stuff about Github ([here's an example](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580428524613&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=http%3A%2F%2Fwww.wired.com%2F2015%2F06%2Fproblem-putting-worlds-code-github%2F&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=here%27s%20an%20example)) but my simple noob question is why aren't efforts towards a free and open "version" ?” - ->**Twizmwazin**: ”GitLab is sorta pushing there.” - -[More at Reddit](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580429720714&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=https%3A%2F%2Fwww.reddit.com%2Fr%2Flinux%2Fcomments%2F45jy59%2Fthe_popularity_of_git_and_github%2F&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=More%20at%20Reddit) - -## DistroWatch reviews XStream Desktop 153 - -XStreamOS is a version of Solaris created by Sonicle. XStream Desktop brings the power of Solaris to desktop users, and distrohoppers might be interested in checking it out. DistroWatch did a full review of XStream Desktop 153 and found that it performed fairly well. - -Jesse Smith reports for DistroWatch: - ->I think XStream Desktop does a lot of things well. Admittedly, my trial got off to a rocky start when the operating system would not boot on my hardware and I could not get the desktop to use my display's full screen resolution when running in VirtualBox. However, after that, XStream performed fairly well. The installer works well, the operating system automatically sets up and uses boot environments, insuring we can recover the system if something goes wrong. The package management tools work well and XStream ships with a useful collection of software. - ->I did run into a few problems playing media, specifically getting audio to work. I am not sure if that is another hardware compatibility issue or a problem with the media software that ships with the operating system. On the other hand, tools such as the web browser, e-mail, productivity suite and configuration tools all worked well. - ->What I appreciate about XStream the most is that the operating system is a branch of the OpenSolaris family that is being kept up to date. Other derivatives of OpenSolaris tend to lag behind, at least with desktop software, but XStream is still shipping recent versions of Firefox and LibreOffice. - ->For me personally, XStream is missing a few components, like a printer manager, multimedia support and drivers for my specific hardware. Other aspects of the operating system are quite attractive. I like the way the developers have set up LXDE, I like the default collection of software and I especially like the way file system snapshots and boot environments are enabled out of the box. Most Linux distributions, openSUSE aside, have not caught on to the usefulness of boot environments yet and I hope it is a technology that is picked up by more projects. - -[More at DistroWatch](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580434172315&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=http%3A%2F%2Fdistrowatch.com%2Fweekly.php%3Fissue%3D20160215%23xstreamos&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=More%20at%20DistroWatch) - -## Street Fighter V and SteamOS - -Street Fighter is one of the most well known game franchises of all time, and now [Capcom has announced](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580435418216&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=http%3A%2F%2Fsteamcommunity.com%2Fgames%2F310950%2Fannouncements%2Fdetail%2F857177755595160250&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=Capcom%20has%20announced) that Street Fighter V will be coming to Linux and SteamOS in the spring. This is great news for Linux gamers. - -Joe Parlock reports for Destructoid: - ->Are you one of the less than one percent of Steam users who play on a Linux-based system? Are you part of the even smaller percentage of people who play on Linux and are excited for Street Fighter V? Well, I’ve got some good news for you. - ->Capcom has announced via Steam that Street Fighter V will be coming to SteamOS and other Linux operating systems sometime this spring. It’ll come at no extra cost, so those who already own the PC build of the game will just be able to install it on Linux and be good to go. - -[More at Destructoid](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580435418216&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=http%3A%2F%2Fsteamcommunity.com%2Fgames%2F310950%2Fannouncements%2Fdetail%2F857177755595160250&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=Capcom%20has%20announced) - -Did you miss a roundup? Check the [Eye On Open home page](http://www.infoworld.com/blog/eye-on-open/) to get caught up with the latest news about open source and Linux. - ------------------------------------------------------------------------------- - -via: http://www.infoworld.com/article/3033059/linux/what-do-linux-developers-think-of-git-and-github.html - -作者:[Jim Lynch][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.infoworld.com/author/Jim-Lynch/ - diff --git a/sources/tech/20160416 A newcomer's guide to navigating OpenStack Infrastructure.md b/sources/tech/20160416 A newcomer's guide to navigating OpenStack Infrastructure.md deleted file mode 100644 index 25dc193fdc..0000000000 --- a/sources/tech/20160416 A newcomer's guide to navigating OpenStack Infrastructure.md +++ /dev/null @@ -1,88 +0,0 @@ -translating by kylepeng93 -A newcomer's guide to navigating OpenStack Infrastructure -=========================================================== - -New contributors to OpenStack are welcome, but having a road map for navigating within this maturing, fast-paced open source community doesn't hurt. At OpenStack Summit in Austin, [Paul Belanger][1] (Red Hat, Inc.), [Elizabeth K. Joseph][2] (HPE), and [Christopher Aedo][3] (IBM) will lead a session on [OpenStack Infrastructure for Beginners][4]. In this interview, they offer tips and resources to help onboard new OpenStack contributors. - -![](https://opensource.com/sites/default/files/images/life/Interview%20banner%20Q%26A.png) - -**Your talk description says you'll be "diving into the heart of infrastructure and explain everything you need to know about the systems that keep OpenStack working." That's a tall order for a 40-minute time slot. What are the top things beginners should know about OpenStack infrastructure?** - -**Elizabeth K. Joseph (EKJ)**: We don't use GitHub for OpenStack patches. This is something that trips up a lot of new contributors because we do maintain mirrors of all our repositories on GitHub for historical reasons. Instead we use a fully open source code review and continuous integration (CI) system maintained by the OpenStack Infrastructure team. Relatedly, since we run a CI system, every change proposed to OpenStack is tested before merging. - -**Paul Belanger (PB)**: A lot of passionate people in the project, so don't get discouraged if your patch gets a -1. - -**Christopher Aedo (CA)**: The community wants to help you succeed, don't be afraid to ask questions or ask for pointers to more information to improve your understanding. - -### Which online resources would you recommend for beginners to fill in the holes for what you can't cover in your talk? - -**PB**: Definitely our [OpenStack Project Infrastructure documentation][5]. At lot of effort has been taken to keep it up to date as much as possible. Every system used in running OpenStack as a project has a dedicated page, even the OpenStack cloud the Infrastructure teams is bringing online. - -**EKJ**: I'll echo what Paul said about the Infrastructure documentation, and add that we love seeing patches from folks who are learning. We often don't realize what we're missing in terms of documentation until someone asks. So read, learn, and then help us fill in the gaps. You can ask questions on the [openstack-infra mailing list][6] or in our IRC channel at #openstack-infra on Freenode. - -**CA**: I love [this detailed post][7] about building images, by Ian Wienand. - -### Which "gotchas" should new OpenStack contributors look out for? - -**EKJ**: Contributing is not just about submitting new code and new features; the OpenStack community places a very high value on doing code reviews. If you want people to look at a patch you submitted, consider reviewing some of the work of others and providing clear and constructive feedback. The more your fellow contributors know about your work and see you doing reviews, the more likely you'll get your code reviewed in a timely manner. - -**CA**: I see a lot of newcomers getting tripped up with [Gerrit][8]. Read through the [developer workflow][9] in the Developers Guide, and then maybe read through it one more time. If you're not used to Gerrit, it can seem confusing and overwhelming at first, but walking through a few code reviews usually makes it all come together. Also, I'm a big fan of IRC. It can be a great place to get help, but it's best if you can maintain a persistent presence so people can answer your questions even if you're not "there" at that particular moment. (Read [IRC, the secret to success in open source][10].) You don't need to be "always on," but the ability to easily scroll back in a channel and catch up on a conversation can be invaluable. - -**PB**: I agree with both Elizabeth and Chris—Gerrit is what to look out for. It is going to be the hub of your development effort. Not only will you be submitting code for people to review, but you'll also be reviewing other contributors' code. Watch out for the Gerrit UI; it can be confusing at times. I'd recommend trying out [Gertty][11], which is a console-based interface to the Gerrit Code Review system, which happens to be a project driven by OpenStack Infrastructure. - -### What resources do you recommend for beginners to help them network with other OpenStack contributors? - -**PB**: For me, it was using IRC and joining the #openstack-infra channel on Freenode ([IRC logs][12]). There is a lot of fantastic information and people in that channel. You get to see the day-to-day operations of the OpenStack project, and once you know how the project works, you'll have a better understanding on how to contribute to its future. - -**CA**: I want to second that note for IRC; staying on IRC throughout the day made a huge difference for me in terms of feeling informed and connected. It's also such a great way to get help when you're stuck with someone on one of the projects—the ones with active IRC channels always have someone around willing to get your issues sorted out. - -**EKJ**: The [openstack-dev mailing list][13] is quite important for staying up to date with news about projects you're working on inside of OpenStack, so I recommend subscribing to that. The mailing list uses subject tags to separate projects, so you can instruct your email client to use those and focus on threads that impact projects you care about. Beyond online resources, many OpenStack groups have popped up all over the world that serve the needs of both users and contributors to OpenStack, and many of them routinely have talks and events with key OpenStack contributors. You can search on Meetup.com in your area, or search on [groups.openstack.org][14] to see if there is an OpenStack group in your area. Finally, there are the [OpenStack Summits][15], which happen every six months, and where we'll be giving our Infrastructure talk. In their current format, the summits consist of both a user conference and a developer conference in one space to talk about everything related to OpenStack, past, present, and future. - -### In which areas does OpenStack need to improve to become more beginner-friendly? - -**PB**: I think our [account-setup][16] process could be made easier for new contributors, especially how many steps are needed to submit your first patch. There is a large cost to enroll into OpenStack development model, which maybe be too much for contributors; however, once enrolled, the model works fantastic for developers. - -**CA**: We have a very pro-developer community, but the focus is on developing OpenStack itself, with less consideration given to the users of OpenStack clouds. We need to bring in application developers and encourage more people to develop things that run beautifully on OpenStack clouds, and encourage them to share those apps in the [Community App Catalog][17]. We can do this by continuing to improve our API standards and by ensuring different libraries (like libcloud, phpopencloud, and others) continue to work reliably for developers. Oh, also by sponsoring more OpenStack hackathons! All these things can ease entry for newcomers, which will lead to them sticking around. - -**EKJ**: I've worked on open source software for many years, but for a large number of OpenStack developers, this is the first open source project they've every worked on. I've found that their proprietary software background doesn't prepare them for the open source ideals, methodologies, and collaboration techniques used in an open source project. I'd love to see us do a better job of welcoming people who have this proprietary software background and working with them so they can truly understand the value of what they're working on in the open source software community. - -### I think 2016 is shaping up to be the Year of the Open Source Haiku. Explain OpenStack to beginners via Haiku. - -**PB**: OpenStack runs clouds If you enjoy free software Submit your first patch - -**CA**: In the near future OpenStack will rule the world Help make it happen! - -**EKJ**: OpenStack is free Deploy on your own servers And run your own cloud! - -*Paul, Elizabeth*, and Christopher will be [speaking at OpenStack Summit][18] in Austin on Monday, April 25, starting at 11:15am. - - ------------------------------------------------------------------------------- - -via: https://opensource.com/business/16/4/interview-openstack-infrastructure-beginners - -作者:[linux.com][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://rikkiendsley.com/ -[1]: https://twitter.com/pabelanger -[2]: https://twitter.com/pleia2 -[3]: https://twitter.com/docaedo -[4]: https://www.openstack.org/summit/austin-2016/summit-schedule/events/7337 -[5]: http://docs.openstack.org/infra/system-config/ -[6]: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-infra -[7]: https://www.technovelty.org/openstack/image-building-in-openstack-ci.html -[8]: https://code.google.com/p/gerrit/ -[9]: http://docs.openstack.org/infra/manual/developers.html#development-workflow -[10]: https://developer.ibm.com/opentech/2015/12/20/irc-the-secret-to-success-in-open-source/ -[11]: https://pypi.python.org/pypi/gertty -[12]: http://eavesdrop.openstack.org/irclogs/%23openstack-infra/ -[13]: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev -[14]: https://groups.openstack.org/ -[15]: https://www.openstack.org/summit/ -[16]: http://docs.openstack.org/infra/manual/developers.html#account-setup -[17]: https://apps.openstack.org/ -[18]: https://www.openstack.org/summit/austin-2016/summit-schedule/events/7337 diff --git a/sources/tech/20160512 Bitmap in Linux Kernel.md b/sources/tech/20160512 Bitmap in Linux Kernel.md index b7e832ba0a..adffc9d049 100644 --- a/sources/tech/20160512 Bitmap in Linux Kernel.md +++ b/sources/tech/20160512 Bitmap in Linux Kernel.md @@ -1,3 +1,4 @@ +[Translating by cposture 2016.06.29] Data Structures in the Linux Kernel ================================================================================ diff --git a/sources/tech/20160530 Install LEMP with MariaDB 10, PHP 7 and HTTP 2.0 Support for Nginx on Ubuntu 16.04.md b/sources/tech/20160530 Install LEMP with MariaDB 10, PHP 7 and HTTP 2.0 Support for Nginx on Ubuntu 16.04.md index e6b143cc00..acb98b2d20 100644 --- a/sources/tech/20160530 Install LEMP with MariaDB 10, PHP 7 and HTTP 2.0 Support for Nginx on Ubuntu 16.04.md +++ b/sources/tech/20160530 Install LEMP with MariaDB 10, PHP 7 and HTTP 2.0 Support for Nginx on Ubuntu 16.04.md @@ -1,3 +1,5 @@ +Translating by GitFuture + Install LEMP with MariaDB 10, PHP 7 and HTTP 2.0 Support for Nginx on Ubuntu 16.04 ===================================================================================== diff --git a/sources/tech/20160601 Learn Python Control Flow and Loops to Write and Tune Shell Scripts – Part 2.md b/sources/tech/20160601 Learn Python Control Flow and Loops to Write and Tune Shell Scripts – Part 2.md deleted file mode 100644 index 6a65df8d49..0000000000 --- a/sources/tech/20160601 Learn Python Control Flow and Loops to Write and Tune Shell Scripts – Part 2.md +++ /dev/null @@ -1,285 +0,0 @@ -translating by wi-cuckoo -Learn Python Control Flow and Loops to Write and Tune Shell Scripts – Part 2 -=============================================================================== - -In the previous article of this [Python series][1] we shared a brief introduction to Python, its command-line shell, and the IDLE. We also demonstrated how to perform arithmetic calculations, how to store values in variables, and how to print back those values to the screen. Finally, we explained the concepts of methods and properties in the context of Object Oriented Programming through a practical example. - -![](http://www.tecmint.com/wp-content/uploads/2016/06/Write-Shell-Scripts-in-Python-Programming.png) ->Write Linux Shell Scripts in Python Programming - -In this guide we will discuss control flow (to choose different courses of action depending on information entered by a user, the result of a calculation, or the current value of a variable) and loops (to automate repetitive tasks) and then apply what we have learned so far to write a simple shell script that will display the operating system type, the hostname, the kernel release, version, and the machine hardware name. - -This example, although basic, will help us illustrate how we can leverage Python OOP’s capabilities to write shell scripts easier than using regular bash tools. - -In other words, we want to go from - -``` -# uname -snrvm -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/05/Check-Hostname-of-Linux.png) ->Check Hostname of Linux - -to - -![](http://www.tecmint.com/wp-content/uploads/2016/05/Check-Linux-Hostname-Using-Python-Script.png) ->Check Linux Hostname Using Python Script - -or - -![](http://www.tecmint.com/wp-content/uploads/2016/05/Script-to-Check-Linux-System-Information.png) ->Script to Check Linux System Information - -Looks pretty, doesn’t it? Let’s roll up our sleeves and make it happen. - -### Control flow in Python - -As we said earlier, control flow allows us to choose different outcomes depending on a given condition. Its most simple implementation in Python is an if / else clause. - -The basic syntax is: - -``` -if condition: - # action 1 -else: - # action 2 -``` - -When condition evaluates to true, the code block below will be executed (represented by `# action 1`. Otherwise, the code under else will be run. -A condition can be any statement that can evaluate to either true or false. - -For example: - -1. 1 < 3 # true - -2. firstName == “Gabriel” # true for me, false for anyone not named Gabriel - - - In the first example we compared two values to determine if one is greater than the other. - - In the second example we compared firstName (a variable) to determine if, at the current execution point, its value is identical to “Gabriel” - - The condition and the else statement must be followed by a colon (:) - - Indentation is important in Python. Lines with identical indentation are considered to be in the same code block. - -Please note that the if / else statement is only one of the many control flow tools available in Python. We reviewed it here since we will use it in our script later. You can learn more about the rest of the tools in the [official docs][2]. - -### Loops in Python - -Simply put, a loop is a sequence of instructions or statements that are executed in order as long as a condition is true, or once per item in a list. - -The most simple loop in Python is represented by the for loop iterates over the items of a given list or string beginning with the first item and ending with the last. - -Basic syntax: - -``` -for x in example: - # do this -``` - -Here example can be either a list or a string. If the former, the variable named x represents each item in the list; if the latter, x represents each character in the string: - -``` ->>> rockBands = [] ->>> rockBands.append("Roxette") ->>> rockBands.append("Guns N' Roses") ->>> rockBands.append("U2") ->>> for x in rockBands: - print(x) -or ->>> firstName = "Gabriel" ->>> for x in firstName: - print(x) -``` - -The output of the above examples is shown in the following image: - -![](http://www.tecmint.com/wp-content/uploads/2016/05/Learn-Loops-in-Python.png) ->Learn Loops in Python - -### Python Modules - -For obvious reasons, there must be a way to save a sequence of Python instructions and statements in a file that can be invoked when it is needed. - -That is precisely what a module is. Particularly, the os module provides an interface to the underlying operating system and allows us to perform many of the operations we usually do in a command-line prompt. - -As such, it incorporates several methods and properties that can be called as we explained in the previous article. However, we need to import (or include) it in our environment using the import keyword: - -``` ->>> import os -``` - -Let’s print the current working directory: - -``` ->>> os.getcwd() -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/05/Learn-Python-Modules.png) ->Learn Python Modules - -Let’s now put all of this together (along with the concepts discussed in the previous article) to write the desired script. - -### Python Script - -It is considered good practice to start a script with a statement that indicates the purpose of the script, the license terms under which it is released, and a revision history listing the changes that have been made. Although this is more of a personal preference, it adds a professional touch to our work. - -Here’s the script that produces the output we shown at the top of this article. It is heavily commented so that you can understand what’s happening. - -Take a few minutes to go through it before proceeding. Note how we use an if / else structure to determine whether the length of each field caption is greater than the value of the field itself. - -Based on the result, we use empty characters to fill in the space between a field caption and the next. Also, we use the right number of dashes as separator between the field caption and its value below. - -``` -#!/usr/bin/python3 -# Change the above line to #!/usr/bin/python if you don't have Python 3 installed - -# Script name: uname.py -# Purpose: Illustrate Python's OOP capabilities to write shell scripts more easily -# License: GPL v3 (http://www.gnu.org/licenses/gpl.html) - -# Copyright (C) 2016 Gabriel Alejandro Cánepa -# ​Facebook / Skype / G+ / Twitter / Github: gacanepa -# Email: gacanepa (at) gmail (dot) com - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# REVISION HISTORY -# DATE VERSION AUTHOR CHANGE DESCRIPTION -# ---------- ------- -------------- -# 2016-05-28 1.0 Gabriel Cánepa Initial version - -# Import the os module -import os - -# Assign the output of os.uname() to the the systemInfo variable -# os.uname() returns a 5-string tuple (sysname, nodename, release, version, machine) -# Documentation: https://docs.python.org/3.2/library/os.html#module-os -systemInfo = os.uname() - -# This is a fixed array with the desired captions in the script output -headers = ["Operating system","Hostname","Release","Version","Machine"] - -# Initial value of the index variable. It is used to define the -# index of both systemInfo and headers in each step of the iteration. -index = 0 - -# Initial value of the caption variable. -caption = "" - -# Initial value of the values variable -values = "" - -# Initial value of the separators variable -separators = "" - -# Start of the loop -for item in systemInfo: - if len(item) < len(headers[index]): - # A string containing dashes to the length of item[index] or headers[index] - # To repeat a character(s), enclose it within quotes followed - # by the star sign (*) and the desired number of times. - separators = separators + "-" * len(headers[index]) + " " - caption = caption + headers[index] + " " - values = values + systemInfo[index] + " " * (len(headers[index]) - len(item)) + " " - else: - separators = separators + "-" * len(item) + " " - caption = caption + headers[index] + " " * (len(item) - len(headers[index]) + 1) - values = values + item + " " - # Increment the value of index by 1 - index = index + 1 -# End of the loop - -# Print the variable named caption converted to uppercase -print(caption.upper()) - -# Print separators -print(separators) - -# Print values (items in systemInfo) -print(values) - -# INSTRUCTIONS: -# 1) Save the script as uname.py (or another name of your choosing) and give it execute permissions: -# chmod +x uname.py -# 2) Execute it: -# ./uname.py -``` - -Once you have saved the above script to a file, give it execute permissions and run it as indicated at the bottom of the code: - -``` -# chmod +x uname.py -# ./uname.py -``` - -If you get the following error while attempting to execute the script: - -``` --bash: ./uname.py: /usr/bin/python3: bad interpreter: No such file or directory -``` - -It means you don’t have Python 3 installed. If that is the case, you can either install the package or replace the interpreter line (pay special attention and be very careful if you followed the steps to update the symbolic links to the Python binaries as outlined in the previous article): - -``` -#!/usr/bin/python3 -``` - -with - -``` -#!/usr/bin/python -``` - -which will cause the installed version of Python 2 to execute the script instead. - -**Note**: This script has been tested successfully both in Python 2.x and 3.x. - -Although somewhat rudimentary, you can think of this script as a Python module. This means that you can open it in the IDLE (File → Open… → Select file): - -![](http://www.tecmint.com/wp-content/uploads/2016/05/Open-Python-in-IDLE.png) ->Open Python in IDLE - -A new window will open with the contents of the file. Then go to Run → Run module (or just press F5). The output of the script will be shown in the original shell: - -![](http://www.tecmint.com/wp-content/uploads/2016/05/Run-Python-Script.png) ->Run Python Script - -If you want to obtain the same results with a script written purely in Bash, you would need to use a combination of [awk][3], [sed][4], and resort to complex methods to store and retrieve items in a list (not to mention the use of tr to convert lowercase letters to uppercase). - -In addition, Python provides portability in that all Linux systems ship with at least one Python version (either 2.x or 3.x, sometimes both). Should you need to rely on a shell to accomplish the same goal, you would need to write different versions of the script based on the shell. - -This goes to show that Object Oriented Programming features can become strong allies of system administrators. - -**Note**: You can find [this python script][5] (and others) in one of my GitHub repositories. - -### Summary - -In this article we have reviewed the concepts of control flow, loops / iteration, and modules in Python. We have shown how to leverage OOP methods and properties in Python to simplify otherwise complex shell scripts. - -Do you have any other ideas you would like to test? Go ahead and write your own Python scripts and let us know if you have any questions. Don’t hesitate to drop us a line using the comment form below, and we will get back to you as soon as we can. - --------------------------------------------------------------------------------- - -via: http://www.tecmint.com/learn-python-programming-to-write-linux-shell-scripts/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+tecmint+%28Tecmint%3A+Linux+Howto%27s+Guide%29 - -作者:[Gabriel Cánepa][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://www.tecmint.com/author/gacanepa/ -[1]: http://www.tecmint.com/learn-python-programming-and-scripting-in-linux/ -[2]: http://please%20note%20that%20the%20if%20/%20else%20statement%20is%20only%20one%20of%20the%20many%20control%20flow%20tools%20available%20in%20Python.%20We%20reviewed%20it%20here%20since%20we%20will%20use%20it%20in%20our%20script%20later.%20You%20can%20learn%20more%20about%20the%20rest%20of%20the%20tools%20in%20the%20official%20docs. -[3]: http://www.tecmint.com/use-linux-awk-command-to-filter-text-string-in-files/ -[4]: http://www.tecmint.com/sed-command-to-create-edit-and-manipulate-files-in-linux/ -[5]: https://github.com/gacanepa/scripts/blob/master/python/uname.py diff --git a/sources/tech/20160620 Monitor Linux With Netdata.md b/sources/tech/20160620 Monitor Linux With Netdata.md new file mode 100644 index 0000000000..95156ef108 --- /dev/null +++ b/sources/tech/20160620 Monitor Linux With Netdata.md @@ -0,0 +1,113 @@ +Monitor Linux With Netdata +=== + +Netdata is a real-time resource monitoring tool with a friendly web front-end developed and maintained by [FireHOL][1]. With this tool, you can read charts representing resource utilization of things like CPUs, RAM, disks, network, Apache, Postfix and more. It is similar to other monitoring software like Nagios; however, Netdata is only for real-time monitoring via a web interface. + + +### Understanding Netdata + +There’s currently no authentication, so if you’re concerned about someone getting information about the applications you’re running on your system, you should restrict who has access via a firewall policy. The UI is simplified in a way anyone could look at the graphs and understand what they’re seeing, or at least be impressed by your flashy setup. + +The web front-end is very responsive and requires no Flash plugin. The UI doesn’t clutter things up with unneeded features, but sticks to what it does. At first glance, it may seem a bit much with the hundreds of charts you have access to, but luckily the most commonly needed charts (i.e. CPU, RAM, network, and disk) are at the top. If you wish to drill deeper into the graphical data, all you have to do is scroll down or click on the item in the menu to the right. Netdata even allows you to control the chart with play, reset, zoom and resize with the controls on the bottom right of each chart. + +![](https://fedoramagazine.org/wp-content/uploads/2016/06/Capture-1.png) +>Netdata chart control + +When it comes down to system resources, the software doesn’t need too much either. The creators choose to write the software in C. Netdata doesn’t use much more than ~40MB of RAM. + +![](https://fedoramagazine.org/wp-content/uploads/2016/06/Capture.png) +>Netdata memory usage + +### Download Netdata + +To download this software, you can head over to [Netdata GitHub page][2]. Then click the “Clone or download” green button on the left of the page. You should then be presented with two options. + +#### Via the ZIP file + +One option is to download the ZIP file. This will include everything in the repository; however, if the repository is updated then you will need to download the ZIP file again. Once you download the ZIP file, you can use the `unzip` tool in the command line to extract the contents. Running the following command will extract the contents of the ZIP file into a “`netdata`” folder. + +``` +$ cd ~/Downloads +$ unzip netdata-master.zip +``` + +![](https://fedoramagazine.org/wp-content/uploads/2016/06/Capture-2.png) +>Netdata unzipped + +ou don’t need to add the `-d` option in unzip because their content is inside a folder at the root of the ZIP file. If they didn’t have that folder at the root, unzip would have extracted the contents in the current directory (which can be messy). + +#### Via git + +The next option is to download the repository via git. You will, of course, need git installed on your system. This is usually installed by default on Fedora. If not, you can install git from the command line with the following command. + +``` +$ sudo dnf install git +``` + +After installing git, you will need to “clone” the repository to your system. To do this, run the following command. + +``` +$ git clone https://github.com/firehol/netdata.git +``` + +This will then clone (or make a copy of) the repository in the current working directory. + +### Install Netdata + +There are some packages you will need to build Netdata successfully. Luckily, it’s a single line to install the things you need ([as stated in their installation guide][3]). Running the following command in the terminal will install all of the dependencies you need to use Netdata. + +``` +$ dnf install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autogen automake pkgconfig +``` + +Once the required packages are installed, you will need to cd into the netdata/ directory and run the netdata-installer.sh script. + +``` +$ sudo ./netdata-installer.sh +``` + +You will then be prompted to press enter to build and install the program. If you wish to continue, press enter to be on your way! + +![](https://cdn.fedoramagazine.org/wp-content/uploads/2016/06/Capture-3-600x341.png) +>Netdata install. + +If all goes well, you will have Netdata built, installed, and running on your system. The installer will also add an uninstall script in the same folder as the installer called `netdata-uninstaller.sh`. If you change your mind later, running this script will remove it from your system. + +You can see it running by checking its status via systemctl. + +``` +$ sudo systemctl status netdata +``` + +### Accessing Netdata + +Now that we have Netdata installed and running, you can access the web interface via port 19999. I have it running on a test machine, as shown in the screenshot below. + +![](https://cdn.fedoramagazine.org/wp-content/uploads/2016/06/Capture-4-768x458.png) +>An overview of what Netdata running on your system looks like + +Congratulations! You now have successfully installed and have access to beautiful displays, graphs, and advanced statistics on the performance of your machine. Whether it’s for a personal machine so you can show it off to your friends or for getting deeper insight into the performance of your server, Netdata delivers on performance reporting for any system you choose. + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/monitor-linux-netdata/ + +作者:[Martino Jones][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/monitor-linux-netdata/ +[1]: https://firehol.org/ +[2]: https://github.com/firehol/netdata +[3]: https://github.com/firehol/netdata/wiki/Installation + + + + + + + + diff --git a/sources/tech/20160621 Container technologies in Fedora - systemd-nspawn.md b/sources/tech/20160621 Container technologies in Fedora - systemd-nspawn.md new file mode 100644 index 0000000000..1ec72a3c90 --- /dev/null +++ b/sources/tech/20160621 Container technologies in Fedora - systemd-nspawn.md @@ -0,0 +1,106 @@ +Container technologies in Fedora: systemd-nspawn +=== + +Welcome to the “Container technologies in Fedora” series! This is the first article in a series of articles that will explain how you can use the various container technologies available in Fedora. This first article will deal with `systemd-nspawn`. + +### What is a container? + +A container is a user-space instance which can be used to run a program or an operating system in isolation from the system hosting the container (called the host system). The idea is very similar to a `chroot` or a [virtual machine][1]. The processes running in a container are managed by the same kernel as the host operating system, but they are isolated from the host file system, and from the other processes. + + +### What is systemd-nspawn? + +The systemd project considers container technologies as something that should fundamentally be part of the desktop and that should integrate with the rest of the user’s systems. To this end, systemd provides `systemd-nspawn`, a tool which is able to create containers using various Linux technologies. It also provides some container management tools. + +In many ways, `systemd-nspawn` is similar to `chroot`, but is much more powerful. It virtualizes the file system, process tree, and inter-process communication of the guest system. Much of its appeal lies in the fact that it provides a number of tools, such as `machinectl`, for managing containers. Containers run by `systemd-nspawn` will integrate with the systemd components running on the host system. As an example, journal entries can be logged from a container in the host system’s journal. + +In Fedora 24, `systemd-nspawn` has been split out from the systemd package, so you’ll need to install the `systemd-container` package. As usual, you can do that with a `dnf install systemd-container`. + +### Creating the container + +Creating a container with `systemd-nspawn` is easy. Let’s say you have an application made for Debian, and it doesn’t run well anywhere else. That’s not a problem, we can make a container! To set up a container with the latest version of Debian (at this point in time, Jessie), you need to pick a directory to set up your system in. I’ll be using `~/DebianJessie` for now. + +Once the directory has been created, you need to run `debootstrap`, which you can install from the Fedora repositories. For Debian Jessie, you run the following command to initialize a Debian file system. + +``` +$ debootstrap --arch=amd64 stable ~/DebianJessie +``` + +This assumes your architecture is x86_64. If it isn’t, you must change `amd64` to the name of your architecture. You can find your machine’s architecture with `uname -m`. + +Once your root directory is set up, you will start your container with the following command. + +``` +$ systemd-nspawn -bD ~/DebianJessie +``` + +You’ll be up and running within seconds. You’ll notice something as soon as you try to log in: you can’t use any accounts on your system. This is because systemd-nspawn virtualizes users. The fix is simple: remove -b from the previous command. You’ll boot directly to the root shell in the container. From there, you can just use passwd to set a password for root, or you can use adduser to add a new user. As soon as you’re done with that, go ahead and put the -b flag back. You’ll boot to the familiar login console and you log in with the credentials you set. + +All of this applies for any distribution you would want to run in the container, but you need to create the system using the correct package manager. For Fedora, you would use DNF instead of debootstrap. To set up a minimal Fedora system, you can run the following command, replacing the absolute path with wherever you want the container to be. + +``` +$ sudo dnf --releasever=24 --installroot=/absolute/path/ install systemd passwd dnf fedora-release +``` + +![](https://cdn.fedoramagazine.org/wp-content/uploads/2016/06/Screenshot-from-2016-06-17-15-04-14.png) + +### Setting up the network + +You’ll notice an issue if you attempt to start a service that binds to a port currently in use on your host system. Your container is using the same network interface. Luckily, `systemd-nspawn` provides several ways to achieve separate networking from the host machine. + +#### Local networking + +The first method uses the `--private-network` flag, which only creates a loopback device by default. This is ideal for environments where you don’t need networking, such as build systems and other continuous integration systems. + +#### Multiple networking interfaces + +If you have multiple network devices, you can give one to the container with the `--network-interface` flag. To give `eno1` to my container, I would add the flag `--network-interface=eno1`. While an interface is assigned to a container, the host can’t use it at the same time. When the container is completely shut down, it will be available to the host again. + +#### Sharing network interfaces + +For those of us who don’t have spare network devices, there are other options for providing access to the container. One of those is the `--port` flag. This forwards a port on the container to the host. The format is `protocol:host:container`, where protocol is either `tcp` or `udp`, `host` is a valid port number on the host, and `container` is a valid port on the container. You can omit the protocol and specify only `host:container`. I often use something similar to `--port=2222:22`. + +You can enable complete, host-only networking with the `--network-veth` flag, which creates a virtual Ethernet interface between the host and the container. You can also bridge two connections with `--network-bridge`. + +### Using systemd components + +If the system in your container has D-Bus, you can use systemd’s provided utilities to control and monitor your container. Debian doesn’t include dbus in the base install. If you want to use it with Debian Jessie, you’ll want to run `apt install dbus`. + +#### machinectl + +To easily manage containers, systemd provides the machinectl utility. Using machinectl, you can log in to a container with machinectl login name, check the status with machinectl status name, reboot with machinectl reboot name, or power it off with machinectl poweroff name. + +### Other systemd commands + +Most systemd commands, such as journalctl, systemd-analyze, and systemctl, support containers with the `--machine` option. For example, if you want to see the journals of a container named “foobar”, you can use journalctl `--machine=foobar`. You can also see the status of a service running in this container with `systemctl --machine=foobar` status service. + +![](https://cdn.fedoramagazine.org/wp-content/uploads/2016/06/Screenshot-from-2016-06-17-15-09-25.png) + +### Working with SELinux + +If you’re running with SELinux enforcing (the default in Fedora), you’ll need to set the SELinux context for your container. To do that, you need to run the following two commands on the host system. + +``` +$ semanage fcontext -a -t svirt_sandbox_file_t "/path/to/container(/.*)?" +$ restorecon -R /path/to/container/ +``` + +Make sure you replace “/path/to/container” with the path to your container. For my container, “DebianJessie”, I would run the following: + +``` +$ semanage fcontext -a -t svirt_sandbox_file_t "/home/johnmh/DebianJessie(/.*)?" +$ restorecon -R /home/johnmh/DebianJessie/ +``` + +-------------------------------------------------------------------------------- + +via: http://linoxide.com/linux-how-to/set-nginx-reverse-proxy-centos-7-cpanel/ + +作者:[John M. Harris, Jr.][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://linoxide.com/linux-how-to/set-nginx-reverse-proxy-centos-7-cpanel/ +[1]: https://en.wikipedia.org/wiki/Virtual_machine diff --git a/sources/tech/20160621 Docker Datacenter in AWS and Azure in Few Clicks.md b/sources/tech/20160621 Docker Datacenter in AWS and Azure in Few Clicks.md index aa4a317103..d9431155ff 100644 --- a/sources/tech/20160621 Docker Datacenter in AWS and Azure in Few Clicks.md +++ b/sources/tech/20160621 Docker Datacenter in AWS and Azure in Few Clicks.md @@ -1,5 +1,6 @@ +translated by pspkforever DOCKER DATACENTER IN AWS AND AZURE IN A FEW CLICKS -==================================================== +=================================================== Introducing Docker Datacenter AWS Quickstart and Azure Marketplace Templates production-ready, high availability deployments in just a few clicks. diff --git a/sources/tech/20160621 Flatpak brings standalone apps to Linux.md b/sources/tech/20160621 Flatpak brings standalone apps to Linux.md new file mode 100644 index 0000000000..c2c1b51e7b --- /dev/null +++ b/sources/tech/20160621 Flatpak brings standalone apps to Linux.md @@ -0,0 +1,35 @@ +翻译中:by zky001 +Flatpak brings standalone apps to Linux +=== + +![](https://cdn.fedoramagazine.org/wp-content/uploads/2016/06/flatpak-945x400.jpg) + +The development team behind [Flatpak][1] has [just announced the general availability][2] of the Flatpak desktop application framework. Flatpak (which was also known during development as xdg-app) provides the ability for an application — bundled as a Flatpak — to be installed and run easily and consistently on many different Linux distributions. Applications bundled as Flatpaks also have the ability to be sandboxed for security, isolating them from your operating system, and other applications. Check out the [Flatpak website][3], and the [press release][4] for more information on the tech that makes up the Flatpak framework. + +### Installing Flatpak on Fedora + +For users wanting to run applications bundled as Flatpaks, installation on Fedora is easy, with Flatpak already available in the official Fedora 23 and Fedora 24 repositories. The Flatpak website has [full details on installation on Fedora][5], as well as how to install on Arch, Debian, Mageia, and Ubuntu. [Many applications][6] have builds already bundled with Flatpak — including LibreOffice, and nightly builds of popular graphics applications Inkscape and GIMP. + +### For Application Developers + +If you are an application developer, the Flatpak website also contains some great resources on getting started [bundling and distributing your applications with Flatpak][7]. These resources contain information on using Flakpak SDKs to build standalone, sandboxed Flatpak applications. + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/introducing-flatpak/ + +作者:[Ryan Lerch][a] +译者:[zky001](https://github.com/zky001) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/introducing-flatpak/ +[1]: http://flatpak.org/ +[2]: http://flatpak.org/press/2016-06-21-flatpak-released.html +[3]: http://flatpak.org/ +[4]: http://flatpak.org/press/2016-06-21-flatpak-released.html +[5]: http://flatpak.org/getting.html +[6]: http://flatpak.org/apps.html +[7]: http://flatpak.org/developer.html diff --git a/sources/tech/awk/Part 1 - How to Use Awk and Regular Expressions to Filter Text or String in Files.md b/sources/tech/awk/Part 1 - How to Use Awk and Regular Expressions to Filter Text or String in Files.md deleted file mode 100644 index 6871673536..0000000000 --- a/sources/tech/awk/Part 1 - How to Use Awk and Regular Expressions to Filter Text or String in Files.md +++ /dev/null @@ -1,214 +0,0 @@ -translating by wwy-hust - -How to Use Awk and Regular Expressions to Filter Text or String in Files -============================================================================= - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Linux-Awk-Command-Examples.png) - -When we run certain commands in Unix/Linux to read or edit text from a string or file, we most times try to filter output to a given section of interest. This is where using regular expressions comes in handy. - -### What are Regular Expressions? - -A regular expression can be defined as a strings that represent several sequence of characters. One of the most important things about regular expressions is that they allow you to filter the output of a command or file, edit a section of a text or configuration file and so on. - -### Features of Regular Expression - -Regular expressions are made of: - -- Ordinary characters such as space, underscore(_), A-Z, a-z, 0-9. -- Meta characters that are expanded to ordinary characters, they include: - - `(.)` it matches any single character except a newline. - - `(*)` it matches zero or more existences of the immediate character preceding it. - - `[ character(s) ]` it matches any one of the characters specified in character(s), one can also use a hyphen (-) to mean a range of characters such as [a-f], [1-5], and so on. - - `^` it matches the beginning of a line in a file. - - `$` matches the end of line in a file. - - `\` it is an escape character. - -In order to filter text, one has to use a text filtering tool such as awk. You can think of awk as a programming language of its own. But for the scope of this guide to using awk, we shall cover it as a simple command line filtering tool. - -The general syntax of awk is: - -``` -# awk 'script' filename -``` - -Where `'script'` is a set of commands that are understood by awk and are execute on file, filename. - -It works by reading a given line in the file, makes a copy of the line and then executes the script on the line. This is repeated on all the lines in the file. - -The `'script'` is in the form `'/pattern/ action'` where pattern is a regular expression and the action is what awk will do when it finds the given pattern in a line. - -### How to Use Awk Filtering Tool in Linux - -In the following examples, we shall focus on the meta characters that we discussed above under the features of awk. - -#### A simple example of using awk: - -The example below prints all the lines in the file /etc/hosts since no pattern is given. - -``` -# awk '//{print}'/etc/hosts -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Awk-Command-Example.gif) ->Awk Prints all Lines in a File - -#### Use Awk with Pattern: - -I the example below, a pattern `localhost` has been given, so awk will match line having localhost in the `/etc/hosts` file. - -``` -# awk '/localhost/{print}' /etc/hosts -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-Command-with-Pattern.gif) ->Awk Print Given Matching Line in a File - -#### Using Awk with (.) wild card in a Pattern - -The `(.)` will match strings containing loc, localhost, localnet in the example below. - -That is to say *** l some_single_character c ***. - -``` -# awk '/l.c/{print}' /etc/hosts -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-with-Wild-Cards.gif) ->Use Awk to Print Matching Strings in a File - -#### Using Awk with (*) Character in a Pattern - -It will match strings containing localhost, localnet, lines, capable, as in the example below: - -``` -# awk '/l*c/{print}' /etc/localhost -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Match-Strings-in-File.gif) ->Use Awk to Match Strings in File - -You will also realize that `(*)` tries to a get you the longest match possible it can detect. - -Let look at a case that demonstrates this, take the regular expression `t*t` which means match strings that start with letter `t` and end with `t` in the line below: - -``` -this is tecmint, where you get the best good tutorials, how to's, guides, tecmint. -``` - -You will get the following possibilities when you use the pattern `/t*t/`: - -``` -this is t -this is tecmint -this is tecmint, where you get t -this is tecmint, where you get the best good t -this is tecmint, where you get the best good tutorials, how t -this is tecmint, where you get the best good tutorials, how tos, guides, t -this is tecmint, where you get the best good tutorials, how tos, guides, tecmint -``` - -And `(*)` in `/t*t/` wild card character allows awk to choose the the last option: - -``` -this is tecmint, where you get the best good tutorials, how to's, guides, tecmint -``` - -#### Using Awk with set [ character(s) ] - -Take for example the set [al1], here awk will match all strings containing character a or l or 1 in a line in the file /etc/hosts. - -``` -# awk '/[al1]/{print}' /etc/hosts -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Print-Matching-Character.gif) ->Use-Awk to Print Matching Character in File - -The next example matches strings starting with either `K` or `k` followed by `T`: - -``` -# awk '/[Kk]T/{print}' /etc/hosts -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Print-Matched-String-in-File.gif) ->Use Awk to Print Matched String in File - -#### Specifying Characters in a Range - -Understand characters with awk: - -- `[0-9]` means a single number -- `[a-z]` means match a single lower case letter -- `[A-Z]` means match a single upper case letter -- `[a-zA-Z]` means match a single letter -- `[a-zA-Z 0-9]` means match a single letter or number - -Lets look at an example below: - -``` -# awk '/[0-9]/{print}' /etc/hosts -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-To-Print-Matching-Numbers-in-File.gif) ->Use Awk To Print Matching Numbers in File - -All the line from the file /etc/hosts contain at least a single number [0-9] in the above example. - -#### Use Awk with (^) Meta Character - -It matches all the lines that start with the pattern provided as in the example below: - -``` -# awk '/^fe/{print}' /etc/hosts -# awk '/^ff/{print}' /etc/hosts -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Print-All-Matching-Lines-with-Pattern.gif) ->Use Awk to Print All Matching Lines with Pattern - -#### Use Awk with ($) Meta Character - -It matches all the lines that end with the pattern provided: - -``` -# awk '/ab$/{print}' /etc/hosts -# awk '/ost$/{print}' /etc/hosts -# awk '/rs$/{print}' /etc/hosts -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Print-Given-Pattern-String.gif) ->Use Awk to Print Given Pattern String - -#### Use Awk with (\) Escape Character - -It allows you to take the character following it as a literal that is to say consider it just as it is. - -In the example below, the first command prints out all line in the file, the second command prints out nothing because I want to match a line that has $25.00, but no escape character is used. - -The third command is correct since a an escape character has been used to read $ as it is. - -``` -# awk '//{print}' deals.txt -# awk '/$25.00/{print}' deals.txt -# awk '/\$25.00/{print}' deals.txt -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-with-Escape-Character.gif) ->Use Awk with Escape Character - -### Summary - -That is not all with the awk command line filtering tool, the examples above a the basic operations of awk. In the next parts we shall be advancing on how to use complex features of awk. Thanks for reading through and for any additions or clarifications, post a comment in the comments section. - --------------------------------------------------------------------------------- - -via: http://www.tecmint.com/use-linux-awk-command-to-filter-text-string-in-files/ - -作者:[Aaron Kili][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://www.tecmint.com/author/aaronkili/ diff --git a/sources/tech/awk/Part 3 - How to Use Awk to Filter Text or Strings Using Pattern Specific Actions.md b/sources/tech/awk/Part 3 - How to Use Awk to Filter Text or Strings Using Pattern Specific Actions.md deleted file mode 100644 index f6aeb69e57..0000000000 --- a/sources/tech/awk/Part 3 - How to Use Awk to Filter Text or Strings Using Pattern Specific Actions.md +++ /dev/null @@ -1,83 +0,0 @@ -How to Use Awk to Filter Text or Strings Using Pattern Specific Actions -========================================================================= - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Filter-Text-or-Strings-Using-Pattern.png) - -In the third part of the Awk command series, we shall take a look at filtering text or strings based on specific patterns that a user can define. - -Sometimes, when filtering text, you want to indicate certain lines from an input file or lines of strings based on a given condition or using a specific pattern that can be matched. Doing this with Awk is very easy, it is one of the great features of Awk that you will find helpful. - -Let us take a look at an example below, say you have a shopping list for food items that you want to buy, called food_prices.list. It has the following list of food items and their prices. - -``` -$ cat food_prices.list -No Item_Name Quantity Price -1 Mangoes 10 $2.45 -2 Apples 20 $1.50 -3 Bananas 5 $0.90 -4 Pineapples 10 $3.46 -5 Oranges 10 $0.78 -6 Tomatoes 5 $0.55 -7 Onions 5 $0.45 -``` - -And then, you want to indicate a `(*)` sign on food items whose price is greater than $2, this can be done by running the following command: - -``` -$ awk '/ *\$[2-9]\.[0-9][0-9] */ { print $1, $2, $3, $4, "*" ; } / *\$[0-1]\.[0-9][0-9] */ { print ; }' food_prices.list -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Filter-and-Print-Text-Using-Awk.gif) ->Print Items Whose Price is Greater Than $2 - -From the output above, you can see that the there is a `(*)` sign at the end of the lines having food items, mangoes and pineapples. If you check their prices, they are above $2. - -In this example, we have used used two patterns: - -- the first: `/ *\$[2-9]\.[0-9][0-9] */` gets the lines that have food item price greater than $2 and -- the second: `/*\$[0-1]\.[0-9][0-9] */` looks for lines with food item price less than $2. - -This is what happens, there are four fields in the file, when pattern one encounters a line with food item price greater than $2, it prints all the four fields and a `(*)` sign at the end of the line as a flag. - -The second pattern simply prints the other lines with food price less than $2 as they appear in the input file, food_prices.list. - -This way you can use pattern specific actions to filter out food items that are priced above $2, though there is a problem with the output, the lines that have the `(*)` sign are not formatted out like the rest of the lines making the output not clear enough. - -We saw the same problem in Part 2 of the awk series, but we can solve it in two ways: - -1. Using printf command which is a long and boring way using the command below: - -``` -$ awk '/ *\$[2-9]\.[0-9][0-9] */ { printf "%-10s %-10s %-10s %-10s\n", $1, $2, $3, $4 "*" ; } / *\$[0-1]\.[0-9][0-9] */ { printf "%-10s %-10s %-10s %-10s\n", $1, $2, $3, $4; }' food_prices.list -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Filter-and-Print-Items-Using-Awk-and-Printf.gif) ->Filter and Print Items Using Awk and Printf - -2. Using $0 field. Awk uses the variable 0 to store the whole input line. This is handy for solving the problem above and it is simple and fast as follows: - -``` -$ awk '/ *\$[2-9]\.[0-9][0-9] */ { print $0 "*" ; } / *\$[0-1]\.[0-9][0-9] */ { print ; }' food_prices.list -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/04/Filter-and-Print-Items-Using-Awk-and-Variable.gif) ->Filter and Print Items Using Awk and Variable - -Conclusion -That’s it for now and these are simple ways of filtering text using pattern specific action that can help in flagging lines of text or strings in a file using Awk command. - -Hope you find this article helpful and remember to read the next part of the series which will focus on using comparison operators using awk tool. - - --------------------------------------------------------------------------------- - -via: http://www.tecmint.com/awk-filter-text-or-string-using-patterns/ - -作者:[Aaron Kili][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://www.tecmint.com/author/aaronkili/ - diff --git a/sources/tech/awk/Part 6 - How to Use ‘next’ Command with Awk in Linux.md b/sources/tech/awk/Part 6 - How to Use ‘next’ Command with Awk in Linux.md deleted file mode 100644 index f272dabcce..0000000000 --- a/sources/tech/awk/Part 6 - How to Use ‘next’ Command with Awk in Linux.md +++ /dev/null @@ -1,76 +0,0 @@ -How to Use ‘next’ Command with Awk in Linux -============================================= - -![](http://www.tecmint.com/wp-content/uploads/2016/06/Use-next-Command-with-Awk-in-Linux.png) - -In this sixth part of Awk series, we shall look at using `next` command, which tells Awk to skip all remaining patterns and expressions that you have provided, but instead read the next input line. - -The `next` command helps you to prevent executing what I would refer to as time-wasting steps in a command execution. - -To understand how it works, let us consider a file called food_list.txt that looks like this: - -``` -Food List Items -No Item_Name Price Quantity -1 Mangoes $3.45 5 -2 Apples $2.45 25 -3 Pineapples $4.45 55 -4 Tomatoes $3.45 25 -5 Onions $1.45 15 -6 Bananas $3.45 30 -``` - -Consider running the following command that will flag food items whose quantity is less than or equal to 20 with a `(*)` sign at the end of each line: - -``` -# awk '$4 <= 20 { printf "%s\t%s\n", $0,"*" ; } $4 > 20 { print $0 ;} ' food_list.txt - -No Item_Name Price Quantity -1 Mangoes $3.45 5 * -2 Apples $2.45 25 -3 Pineapples $4.45 55 -4 Tomatoes $3.45 25 -5 Onions $1.45 15 * -6 Bananas $3.45 30 -``` - -The command above actually works as follows: - -- First, it checks whether the quantity, fourth field of each input line is less than or equal to 20, if a value meets that condition, it is printed and flagged with the `(*)` sign at the end using expression one: `$4 <= 20` -- Secondly, it checks if the fourth field of each input line is greater than 20, and if a line meets the condition it gets printed using expression two: `$4 > 20` - -But there is one problem here, when the first expression is executed, a line that we want to flag is printed using: `{ printf "%s\t%s\n", $0,"**" ; }` and then in the same step, the second expression is also checked which becomes a time wasting factor. - -So there is no need to execute the second expression, `$4 > 20` again after printing already flagged lines that have been printed using the first expression. - -To deal with this problem, you have to use the `next` command as follows: - -``` -# awk '$4 <= 20 { printf "%s\t%s\n", $0,"*" ; next; } $4 > 20 { print $0 ;} ' food_list.txt - -No Item_Name Price Quantity -1 Mangoes $3.45 5 * -2 Apples $2.45 25 -3 Pineapples $4.45 55 -4 Tomatoes $3.45 25 -5 Onions $1.45 15 * -6 Bananas $3.45 30 -``` - -After a single input line is printed using `$4 <= 20` `{ printf "%s\t%s\n", $0,"*" ; next ; }`, the `next` command included will help skip the second expression `$4 > 20` `{ print $0 ;}`, so execution goes to the next input line without having to waste time on checking whether the quantity is greater than 20. - -The next command is very important is writing efficient commands and where necessary, you can always use to speed up the execution of a script. Prepare for the next part of the series where we shall look at using standard input (STDIN) as input for Awk. - -Hope you find this how to guide helpful and you can as always put your thoughts in writing by leaving a comment in the comment section below. - --------------------------------------------------------------------------------- - -via: http://www.tecmint.com/use-next-command-with-awk-in-linux/ - -作者:[Aaron Kili][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://www.tecmint.com/author/aaronkili/ diff --git a/sources/tech/awk/Part 7 - How to Read Awk Input from STDIN in Linux.md b/sources/tech/awk/Part 7 - How to Read Awk Input from STDIN in Linux.md deleted file mode 100644 index 157716481a..0000000000 --- a/sources/tech/awk/Part 7 - How to Read Awk Input from STDIN in Linux.md +++ /dev/null @@ -1,73 +0,0 @@ -vim-kakali translating - - -How to Read Awk Input from STDIN in Linux -============================================ - -![](http://www.tecmint.com/wp-content/uploads/2016/06/Read-Awk-Input-from-STDIN.png) - -In the previous parts of the Awk tool series, we looked at reading input mostly from a file(s), but what if you want to read input from STDIN. -In this Part 7 of Awk series, we shall look at few examples where you can filter the output of other commands instead of reading input from a file. - -We shall start with the [dir utility][1] that works similar to [ls command][2], in the first example below, we use the output of `dir -l` command as input for Awk to print owner’s username, groupname and the files he/she owns in the current directory: - -``` -# dir -l | awk '{print $3, $4, $9;}' -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/06/List-Files-Owned-By-User-in-Directory.png) ->List Files Owned By User in Directory - -Take a look at another example where we [employ awk expressions][3], here, we want to print files owned by the root user by using an expression to filter strings as in the awk command below: - -``` -# dir -l | awk '$3=="root" {print $1,$3,$4, $9;} ' -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/06/List-Files-Owned-by-Root-User.png) ->List Files Owned by Root User - -The command above includes the `(==)` comparison operator to help us filter out files in the current directory which are owned by the root user. This is achieved using the expression `$3==”root”`. - -Let us look at another example of where we use a [awk comparison operator][4] to match a certain string. - -Here, we have used the [cat utility][5] to view the contents of a file named tecmint_deals.txt and we want to view the deals of type Tech only, so we shall run the following commands: - -``` -# cat tecmint_deals.txt -# cat tecmint_deals.txt | awk '$4 ~ /tech/{print}' -# cat tecmint_deals.txt | awk '$4 ~ /Tech/{print}' -``` - -![](http://www.tecmint.com/wp-content/uploads/2016/06/Use-Comparison-Operator-to-Match-String.png) ->Use Awk Comparison Operator to Match String - -In the example above, we have used the value `~ /pattern/` comparison operator, but there are two commands to try and bring out something very important. - -When you run the command with pattern tech nothing is printed out because there is no deal of that type, but with Tech, you get deals of type Tech. - -So always be careful when using this comparison operator, it is case sensitive as we have seen above. - -You can always use the output of another command instead as input for awk instead of reading input from a file, this is very simple as we have looked at in the examples above. - -Hope the examples were clear enough for you to understand, if you have any concerns, you can express them through the comment section below and remember to check the next part of the series where we shall look at awk features such as variables, numeric expressions and assignment operators. - --------------------------------------------------------------------------------- - -via: http://www.tecmint.com/read-awk-input-from-stdin-in-linux/ - -作者:[Aaron Kili][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://www.tecmint.com/author/aaronkili/ -[1]: http://www.tecmint.com/linux-dir-command-usage-with-examples/ -[2]: http://www.tecmint.com/15-basic-ls-command-examples-in-linux/ -[3]: http://www.tecmint.com/combine-multiple-expressions-in-awk -[4]: http://www.tecmint.com/comparison-operators-in-awk -[5]: http://www.tecmint.com/13-basic-cat-command-examples-in-linux/ - - - diff --git a/translated/talk/20160523 Driving cars into the future with Linux.md b/translated/talk/20160523 Driving cars into the future with Linux.md deleted file mode 100644 index 9b9d69d68c..0000000000 --- a/translated/talk/20160523 Driving cars into the future with Linux.md +++ /dev/null @@ -1,108 +0,0 @@ - -驾车通往未来Linux -=========================================== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/open-snow-car-osdc-lead.png?itok=IgYZ6mNY) - - -当我开车的时候不认为和 Linux 有多大联系,但是我肯定我是喜欢一个配备有系统的车子,让我按几个按钮语音就可以传给我的妻子母亲以及孩子。同样,这样的系统可以让我选择是否从云端流媒体收听音乐,卫星广播,以及传统的 AM/FM 收音机。我也会得到天气更新以及可以给我的车载信息娱乐 GPS 找到最快的下一个目的地[In-vehicle infotainment][1],以及 IVI 作为行业知名产业,已经普及到最新的汽车生产商。 - -前段时间,我不得坐飞机飞跃数百英里,租一辆车。令人愉快的是,我发现我的租凭车配置了 IVI 技术。任何时候,我只要通过蓝牙连接,上传联系人到系统中,打电话回家给我的家人,让他们知道我已经安全到家了。然后“主人“会知道我再途中还是已经到他们家了。 - -在最近的 [news roundup][2],Scott Nesbitt 引用一篇文章,说福特汽车公司是由它的开源 [Smart Device Link][3](SDL)中间设备框架,对手汽车制造商,支持那个移动手机获得大量的支持。 SDL 是 [GENIVI Alliance][4] 的项目,一个非营利性的致力于建设中间件支持开源的车载信息娱乐系统。根据文献 [[Steven Crumb][5],GENIVI 执行董事,他们 [membership][6] 很广,包括 Daimler 集团,现代,沃尔沃,日产,本田等等 170 个。 - -为了在同行业中保持竞争力,汽车企业需要一个中间设备系统,可以支持当今消费者提供的各种人机界面技术。无论您拥有 Android,iOS 或其他设备,汽车 OEM 厂商希望自己的系统单位能够支持这些。此外,这些的 IVI 系统必须有足够适应能力以支持移动技术的不断下降,半衰期。 OEM 厂商要提供价值服务,并在他们的 IVI 堆栈支持各种为他们的客户添加选择。进入 Linux 和开源软件。 - -除了 GENIVI 的努力下,[Linux Foundation][7] 赞助 [Automotive Grade Linux][8](AGL)工作组,一个软件基金会,致力于寻找针对汽车应用的开源解决方案。虽然 AGL 初期将侧重于 IVI 系统,他们展望不同的分歧,包括 [telematics][9],小心显示器和其他控制系统。 AGL 有超过 50 名成员在这个时候,包括捷豹,丰田,日产,并在 [recent press release][10] 宣布福特、马自达、三菱、和斯巴鲁加入。 - - -为了了解更多信息,我们在这一新鲜兴领域采访了两位领导人。明确地来说,我们想知道是如何被使用的 Linux 和开源软件,如果它们实际上是改变汽车行业的面貌。首先,我们谈谈 [Alison Chaiken][11],在大集团技术的软件工程师和汽车 Linux 专家,网络安全和透明度。她曾任职于 [Alison Chaiken][11] 公司,诺基亚和斯坦福直线性加速器。然后我们用 [Steven Crumb][12],GENIVI 执行董事,谁得到了在开源环境高性能计算(超级计算机和早期的云计算)开始聊天。他说,虽然他再不是一个程序员了,但是他喜欢帮助企业解决开源软件的实际业务问题。 - -### 采访 Alison Chaiken (by [Deb Nicholson][13]) - -#### 你是如何开始对汽车软件空间感兴趣的? - -我是在诺基亚手机产品时, 2009 年该项目被取消。我想,下一步是什么?一位同事正在对 [MeeGo-IVI][15],早期的汽车 Linux 发行版。 “Linux 在汽车是大了,” 我想,所以我在朝着这个方向努力。 - -#### 你能告诉我们你这些日子工作在哪些方面? - -我目前正在启动为使用 Linux 系统增加大货车钻机的安全性和燃油经济性的先进巡航控制。我喜欢在这方面的工作,因为没有人会反对卡车得以提升。 - -#### 目前关于汽车已在近年来砍死几个人故事。开源代码方案可以帮助解决这个问题吗? - -I presented a talk on precisely this topic, on how Linux can (and cannot) contribute to security solutions in automotive at Southern California Linux Expo 2016 ([Slides][16]). Notably, GENIVI and Automotive Grade Linux have published their code and both projects take patches via Git. Please send your fixes upstream! Many eyes make all bugs shallow. -我提出的谈话正是这一主题,就如何 Linux 可以(或不可以)在南加州 2016 年世博会作出贡献的安全解决方案的 Linux汽车([Slides][16])。值得注意的是,GENIVI 和汽车级 Linux 已经公布了他们的代码,这两个项目的 Git 通过采取补丁。请上游发送您的修复!许多眼睛都盯着肤浅的bugs。 - -#### 执法机构和保险公司可以找到很多有关数据用途的驱动程序。它将如何容易成为他们获取这些信息? - -好问题。该专用短程通信标准(IEEE-1609),以保持匿名的 Wi-Fi 安全消息驱动程序。不过,如果你从你的车张贴到 Twitter,有人能够跟踪你。 - -#### 有什么可以开发人员和公民个人一起完成,以确保公民自由受到保护作为汽车技术发展的? - -电子前沿基金会(EFF)一样对汽车保持的问题上,通过什么样的数据可以存储在汽车 “黑盒子”,并在 DMCA 的规定 1201 如何应用于汽车官方渠道评论已经出色的工作了。 - -#### 在未来几年令人兴奋的事情上,那些是你看到的驱动因素? - -自适应巡航控制和防撞系统有足够的预付款来挽救生命。当他们通过运输车队的推出,我真的相信死亡人数会下降。如果这还不是令人兴奋的,我不知道是什么。此外,像自动化停车辅助功能,将会使汽车更容易驾驶,减少汽车相撞事故。 - -#### 有什么是需要人参与以及如何建造? - -汽车 Linux 级开发是开放源代码的,运行在廉价硬件(如树莓派 Pi 2 和中等价位的 Renesas Porter board),任何人都可以购买。 GENIVI 汽车 Linux 的中间设备联盟有很多软件通过 Git 的公开。此外,还有很酷的 [OSVehicle open hardware][17] 汽车平台。 - -#### 这里是 Linux 软件和开放硬件,许多方面具有中等人数预算的参与。如果您有任何疑问,加入我们在 Freenode 上 IRC#automotive。 - -### 采访 Steven Crumb (by Don Watkins) - -#### 关于GENIVI's 对 IVI 为什么那么大 ? - -GENIVI 率先通过使用自由和开源软件,包括 Linux,像车载信息娱乐(IVI)系统的非安全关键汽车软件填补了汽车行业的巨大差距。作为消费者来到期望在他们的车辆相同的功能在智能手机上的软件,以支持 IVI 功能所需的量成倍增长。软件增加量也增加了建设 IVI 系统的成本,从而延缓了上市时间。 - -GENIVI 的使用开源软件和社区发展模式节省了汽车制造商和他们的软件提供商显著大量的资金,而显著减少了产品上市时间。我很兴奋,因为 GENIVI 我们很幸运慢慢从高度结构化和专有的方法来社区为基础的方法不断发展的组织​​领导排序在汽车行业的一场革命。我们还没有完成,但它一直是一个荣幸参加正在产生实实在在的好处的转换。 - -#### 你的庞大会员怎么才可以驱动 GENIVI 方向? - -GENIVI 有很多会员和非会员促进我们的工作。与许多开源项目,任何公司都可以通过简单地贡献代码,修补程序和时间来检验影响的技术输出。随着中说,宝马,奔驰,现代汽车,捷豹路虎,标致雪铁龙,雷诺 / 日产和沃尔沃是所有积极采用者和贡献者 GENIVI 和其他许多 OEM 厂商已经在他们的汽车 IVI 解决方案,广泛使用 GENIVI 的软件。 - -#### 贡献的代码使用了什么许可证? - -GENIVI 采用数量的许可证从(L)GPLv2 许可,以 MPLv2 到 Apache2.0。我们的一些工具使用 Eclipse 许可证。我们有一个[public licensing policy][18],详细说明我们的许可偏好。 - -#### 一个人或一群人如何参与其中?重要的是如何对项目的持续成功的社区贡献? - -GENIVI 完全做它开放发展的在([projects.genivi.org][19]),因此,有兴趣的人在汽车使用开源软件,欢迎参加。这就是说,该联盟能够通过公司 [joining GENIVI][20] 作为成员不断发展的开放基金。 GENIVI 会员享受各种各样的福利,而不是其中最重要的是在已经发展了近六年来 140 家公司全球社区参与。 - -社区是 GENIVI 非常重要的,我们不可能生产和维护我们发展了很多年没有贡献者一个活跃的社区有价值的软件。我们努力做出贡献 GENIVI 简单,只要加入一个 [邮件列表] [21] 并连接到人们在不同的软件项目。我们使用许多开源项目采用的标准做法,并提供高质量的工具和基础设施,以帮助开发人员有宾至如归的感觉,并富有成效。 - -无论在汽车软件某人的熟悉,欢迎他们加入我们的社区。人们已经改装车多年,所以对于许多人来说,是一种天然的抽奖,任何汽车。软件是汽车的新域,GENIVI 希望成为敞开的门有兴趣的人与汽车,开源软件的工作。 - -------------------------------- -via: https://opensource.com/business/16/5/interview-alison-chaiken-steven-crumb - -作者:[Don Watkins][a] -译者:[erlinux](https://github.com/erlinux) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/don-watkins -[1]: https://en.wikipedia.org/wiki/In_car_entertainment -[2]: https://opensource.com/life/16/1/weekly-news-jan-9 -[3]: http://projects.genivi.org/smartdevicelink/home -[4]: http://www.genivi.org/ -[5]: https://www.linkedin.com/in/stevecrumb -[6]: http://www.genivi.org/genivi-members -[7]: http://www.linuxfoundation.org/ -[8]: https://www.automotivelinux.org/ -[9]: https://en.wikipedia.org/wiki/Telematics -[10]: https://www.automotivelinux.org/news/announcement/2016/01/ford-mazda-mitsubishi-motors-and-subaru-join-linux-foundation-and -[11]: https://www.linkedin.com/in/alison-chaiken-3ba456b3 -[12]: https://www.linkedin.com/in/stevecrumb -[13]: https://opensource.com/users/eximious -[14]: https://en.wikipedia.org/wiki/MeeGo -[15]: http://webinos.org/deliverable-d026-target-platform-requirements-and-ipr/automotive/ -[16]: http://she-devel.com/Chaiken_automotive_cybersecurity.pdf -[17]: https://www.osvehicle.com/ -[18]: http://projects.genivi.org/how -[19]: http://projects.genivi.org/ -[20]: http://genivi.org/join -[21]: http://lists.genivi.org/mailman/listinfo/genivi-projects diff --git a/translated/talk/20160531 Why Ubuntu-based Distros Are Leaders.md b/translated/talk/20160531 Why Ubuntu-based Distros Are Leaders.md deleted file mode 100644 index 9d9ce0f418..0000000000 --- a/translated/talk/20160531 Why Ubuntu-based Distros Are Leaders.md +++ /dev/null @@ -1,85 +0,0 @@ -为什么 Ubuntu 家族会占据 Linux 发行版的主导地位? -========================================= - -在过去的数年中,我已经尝试了大量的优秀 Linux 发行版。我印象最深刻的是那些被强大的社区维护的发行版。但是这样的发行版却比他们s所属的社区更受人欢迎。流行的 Linux 发行版吸引着更多的人,通常由于这样的特点使得使用该发行版更加容易。这很明显毫无关系,但一般认为这种说法是正确的。 - - -我想到的一个发行版 [Ubuntu][1]。它属于健壮的 [Debian][2]分支,Ubuntu 不可思议的成为了受欢迎的 Linux 发行版,而且它也衍生出了其他的版本,比如 Linux Mint。在本文中,我会探讨我坚信 Ubuntu 会赢得 Linux 发行版战争的原因,以及它在整个 Linux 桌面领域有着怎样的影响力。 - - -### Ubuntu容易使用 - - -多年前我第一次尝试使用Ubuntu,在这之前我更喜欢使用 KED 桌面。在那个时期,我接触的大多是这种 KDE 桌面环境。主要原因还是 KDE 是大多数新手友好的 Linux 发行版中最受欢迎的。新手友好的发行版有 Knoppix,Simply Mepis, Xandros, Linspire等,另外一些发行版和这些发行版都指出他们的用户趋向于使用 KDE。 - - - -现在KDE能满足我的需求,也没有什么理由去折腾其他的桌面环境了。有一天我的 Debian 安装失败了(由于我个人的操作不当),我决定尝试开发代号为「整洁的公鸭(Ubuntu Dapper Drake)」的 Ubuntu 版本【译者注:ubuntu 6.06 - Dapper Drake(整洁的公鸭),发布日期:2006年6月1日】。那个时候,我对于它的印象比一个屏幕截图还要少,但是我认为它很有趣并且毫无顾忌的使用它。 - - - -Ubuntu Dapper Drake 给我的最大的印象是它的操作很简单。记住,我是来自于 KDE 世界的用户,在 KDE 上要想改变菜单的设置就有15钟方法。Ubuntu 图形界面的安装启动极具极简主义。 - -时间来到2016年,最新的版本号是16.04:我们有多种可用的 Ubuntu 衍生版本,许多的都是基于 Ubuntu 的。所有的 Ubuntu 风格和公用发行版的核心都被设计的容易使用。并且发行版想要增大用户基数的时候,这就是最重要的原因。 - - -### Ubuntu LTS - -过去,我几乎一直坚持使用 LTS(Long Term Support)发行版作为我的主要桌面系统。10月份的发行版很适合我测试硬盘驱动器,甚至把它用在一个老旧的手提电脑上。我这样做的原因很简单——我没有兴趣在一个作为实验品的电脑上折腾短期发行版。我是个很忙的家伙,我觉得这样会浪费我的时间。 - - -对于我来说,我认为 Ubuntu 提供 LTS 发行版是 Ubuntu 能够变得流行的原因。这样说吧———提供一个大众的桌面 Linux 发行版,这个发行版能够得到长期的充分支持就是它的优势。事实上,Ubuntu 的优势不只这一点,其他的分支在这一点上也做的很好。长期支持版带有一个对新手的友好环境的策略,我认为这就为 Ubuntu 的普及带来了莫大的好处。 - - -### Ubuntu Snap 包 - - -以前,用户在他们的系统上使用很多 PPA(personal package archive个人软件包档案),他们总会抱怨它获得新的软件名称的能力。不好的是,这种技术也有缺点。它工作的时候带有任意的软件名称,而 PPA 却没有发现,这种情况很常见。 - - -现在有了[Snap 包][3] 。当然这不是一个全新的概念,过去已经进行了类似的尝试。用户不必要在最新的 Ubuntu 发行版上运行最新的软件,我认为这才是 Snap 将要长期提供给 Ubuntu 用户的东西。然而我仍然认为我们将会看到 Snap 淘汰的的那一天,我很期待看到一个在稳定的发行版上运行的优秀软件。 - - - -如果你要运行很多软件,那么 Snap 包实际使用的硬盘空间很明显存在问题。不仅如此,大多数 Ubuntu 软件也是通过由官方开发的 deb 包进行管理的。当后者需要花费一些时间的时候,这个问题可以通过 Snap 使用更大的硬盘驱动器空间得到解决。 - - - -### Ubuntu 社区 - -首先,我承认大多数主要的 Linux 发行版都有强大的社区。然而,我坚信 Ubuntu 社区的成员是最多样化的,他们来自各行各业。例如,我们有一个论坛来分类不同的苹果硬件对于游戏的支持程度。这些大量的专业讨论特别广泛。 - - -除过论坛,Ubuntu 也提供了一个很正式的社区组织。这个组织包括一个委员会,技术板块,[各地的团队LoCo teams][4](Ubuntu Local Community Teams)和开发人员板块。还有很多,但是这些都是我知道的社区组织部分。 - - -我们还有一个[Ubuntu 问答][5]板块。我认为,这种特色可以代替人们从论坛寻求帮助的方式,我发现在这个网站你得到有用信息的可能行更大。不仅如此,那些提供的解决方案中被选出的最精准的答案也会被写入到官方文档中。 - - -### Ubuntu 的未来 - - -我认为 Ubuntu 的 Unity 接口【译者注:Unity 是 Canonical 公司为 Ubuntu 操作系统的 GNOME 桌面环境开发的图形化 shell】在增加桌面舒适性上少有作为。我能理解其中的缘由,现在它主要做一些诸如可以使开发团队的工作更轻松的事情。但是最终,我还是希望 Unity 可以为 Ubuntu MATE 和 Linux Mint 的普及铺平道路。 - - -我最好奇的一点是 Ubuntu's IRC(Internet Relay Chat) 和邮件列表的发展【译者注:可以在 Ubuntu LoCo Teams IRC Chat上提问关于地方团队和计划的事件的问题,也可以和一些不同团队的成员进行交流】。事实是,他们都不能像 Ubuntu 问答板块那样为它们自己增添一些好的文档。至于邮件列表,我一直认为这对于合作是一种很痛苦的过时方法,但这仅仅是我的个人看法——其他人可能有不同的看法,也可能会认为它很好。 - -你说什么?你认为 Ubuntu 将来会剩下一点主要的使用者?也许你相信 Arch 和 Linux Mint 或者其他的发行版会在普及度上打败 Ubuntu 。 既然这样,那请大声说出你最喜爱的发行版。如果这个发行版是 Ubuntu 衍生版 ,说说你为什么更喜欢它而不是 Ubuntu 本身。如果不出意外,Ubuntu 会成为构建其他发行版的基础,我想很多人都是这样认为的。 - - --------------------------------------------------------------------------------- - -via: http://www.datamation.com/open-source/why-ubuntu-based-distros-are-leaders.html - -作者:[Matt Hartley][a] -译者:[vim-kakali](https://github.com/vim-kakali) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://www.datamation.com/author/Matt-Hartley-3080.html -[1]: http://www.ubuntu.com/ -[2]: https://www.debian.org/ -[3]: http://www.datamation.com/open-source/ubuntu-snap-packages-the-good-the-bad-the-ugly.html -[4]: http://loco.ubuntu.com/ -[5]: http://askubuntu.com/ diff --git a/translated/tech/20160218 What do Linux developers think of Git and GitHub.md b/translated/tech/20160218 What do Linux developers think of Git and GitHub.md new file mode 100644 index 0000000000..a0eb63506e --- /dev/null +++ b/translated/tech/20160218 What do Linux developers think of Git and GitHub.md @@ -0,0 +1,93 @@ +Linux 开发者如何看待 Git 和 Github? +===================================================== + +**同样在今日的开源摘要: DistroWatch 评估 XStream 桌面 153 版本,街头霸王 V 即将在这个春天进入 Linux 和 SteamOS** + +## Linux 开发者如何看待 Git 和 Github? + +Git 和 Github 在 Linux 开发者中有很高的知名度。但是开发者如何看待它们呢?另外,Github 是不是真的和 Git 是一个意思?一个 Linux reddit 用户最近问到了这个问题,并且得到了很有意思的答案。 + +Dontwakemeup46 提问: + +> 我正在学习 Git 和 Github。我感兴趣的是社区如何看待两者?据我所知,Git 和 Github 应用十分广泛。但是 Git 或 Github 有没有严重的,社区喜欢去修改的问题呢? + +[更多见 Reddit](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580413015211&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=https%3A%2F%2Fwww.reddit.com%2Fr%2Flinux%2Fcomments%2F45jy59%2Fthe_popularity_of_git_and_github%2F&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=More%20at%20Reddit) + +与他志同道合的 Linux reddit 用户回答了他们对于 Git 和 Github的想法: + +>Derenir: “Github 并不隶属于 Git。 + +>Git 是由 Linus Torvalds 开发的。 + +>Github 几乎不支持 Linux。 + +>Github 是一家唯利是图的,企图借助 Git 赚钱的公司。 + +>[https://desktop.github.com/](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580415025712&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&type=U&out=https%3A%2F%2Fdesktop.github.com%2F&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=https%3A%2F%2Fdesktop.github.com%2F) 并没有支持 Linux。” + +>**Bilog78**: “一个简单的更新: Linus Torvalds 已经不再维护 Git了。维护者是 Junio C Hamano,以及 Linus 之后的主要贡献者是Jeff King 和 Shawn O. Pearce。” + +>**Fearthefuture**: “我喜欢 Git,但是不明白人们为什么还要使用 Github。从我的角度,Github 比 Bitbucket 好的一点是用户统计和更大的用户基础。Bitbucket 有无限的免费私有库,更好的 UI,以及更好地继承其他服务,比如说 Jenkins。” + +>**Thunger**: “Gitlab.com 也很不错,特别是你可以在自己的服务器上架设自己的实例。” + +>**Takluyver**: “很多人熟悉 Github 的 UI 以及相关联的服务,像 Travis 。并且很多人都有 Github 账号,所以它是一个很好地存储项目的地方。人们也使用他们的 Github 简况作为一种求职用的作品选辑,所以他们很积极地将更多的项目放在这里。Github 是一个事实上的,存放开源项目的标准。” + +>**Tdammers**: “Git 严重问题在于 UI,它有些违反直觉,到很多用户只使用一些容易记住的咒语程度。” + +Github:最严重的问题在于它是私人拥有的解决方案;你买了方便,但是代价是你的代码在别人的服务器上面,已经不在你的掌控范围之内了。另一个对于 Github 的普遍批判是它的工作流和 Git 本身的精神不符,特别是 pull requests 工作的方式。最后, Github 垄断代码的托管环境,同时对于多样性是很不好的,这反过来对于旺盛的免费软件社区很重要。” + +>**Dies**: “更重要的是,如果一旦是这样,做过的都做过了,并且我猜我们会被 Github 所困,因为它们控制如此多的项目。” + +>**Tdammers**: “代码托管在别人的服务器上,别人指的是 Github。这对于开源项目来说,并不是什么太大的问题,但是仍然,你无法控制它。如果你在 Github 上有私有项目,唯一的保险在于它将保持私有是 Github 的承诺。如果你决定删除东西,你不能确定东西是否被删除了,或者只是隐藏了。 + +Github 并不自己控制这些项目(你总是可以拿走你的代码,然后托管到别的地方,声明新位置是“官方”的),它只是有比开发者本身有更深的使用权。” + +>**Drelos**: “我已经读了大量的关于 Github 的赞美与批评。(这里有一个[例子](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580428524613&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=http%3A%2F%2Fwww.wired.com%2F2015%2F06%2Fproblem-putting-worlds-code-github%2F&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=here%27s%20an%20example)),但是我的新手问题是为什么不向一个免费开源的版本努力呢?” + +>**Twizmwazin**: “Gitlab 的源码就存在这里” + +[更多见 Reddit](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580429720714&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=https%3A%2F%2Fwww.reddit.com%2Fr%2Flinux%2Fcomments%2F45jy59%2Fthe_popularity_of_git_and_github%2F&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=More%20at%20Reddit) + +## DistroWatch 评估 XStream 桌面 153 版本 + +XStreamOS 是一个由 Sonicle 创建的 Solaris 的一个版本。XStream 桌面将 Solaris 的强大带给了桌面用户,同时新手用户很可能有兴趣体验一下。DistroWatch 对于 XStream 桌面 153 版本做了一个很全面的评估,并且发现它运行相当好。 + +Jesse Smith 为 DistroWatch 报道: + +> 我认为 XStream 桌面做好了很多事情。无可否认地,我的实验陷入了头晕目眩的状态当操作系统无法在我的硬件上启动。同时,当运行在 VirtualBox 中我无法使得桌面使用我显示器的完整分辨率。 + +> 我确实在播放多媒体文件时遇见一些问题,特别是使声卡工作。我不确定是不是另外一个硬件兼容问题,或者一个关于操作系统自带的多媒体软件的问题。另一方面,像 Web 浏览器,电子邮件,生产工具套件以及配置工具这样的工作都工作的很好。 + +> 我最欣赏 XStream 的地方是这个操作系统是 OpenSolaris 家族的一个使用保持最新的分支。OpenSolaris 的其他衍生系统有落后的倾向,至少在桌面软件上,但是 XStream 仍然搭载最新版本的火狐和 LibreOffice。 + +>对我个人来说,XStream 缺少一些组件,比如打印机管理器,多媒体支持和我特定硬件的驱动。这个操作系统的其他方面也是相当吸引人的。我喜欢开发者搭建 LXDE 的方式,软件的默认组合,以及我最喜欢文件系统快照和启动环境开箱即用的方式。大多数的 Linux 发行版,openSUSE 除外,并没有使得启动环境的有用性流行起来。我希望它是一个被更多项目采用的技术。 + +[更多见 DistroWatch](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580434172315&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=http%3A%2F%2Fdistrowatch.com%2Fweekly.php%3Fissue%3D20160215%23xstreamos&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=More%20at%20DistroWatch) + +## 街头霸王 V 和 SteamOS + +街头霸王是最出名的游戏之一,并且 [Capcom 已经宣布](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580435418216&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=http%3A%2F%2Fsteamcommunity.com%2Fgames%2F310950%2Fannouncements%2Fdetail%2F857177755595160250&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=Capcom%20has%20announced) 街头霸王 V 将会在这个春天进入 Linux 和 StreamOS。这对于 Linux 游戏者是非常好的消息。 + +Joe Parlock 为 Destructoid 报道: + +>你是少于 1% 的,在 Linux 系统上玩游戏的 Stream 用户吗?你是更少百分比的,在 Linux 平台上玩游戏,同时很喜欢街头霸王 V 的人之一吗?是的话,我有一些好消息要告诉你。 + +>Capcom 已经宣布,这个春天街头霸王 V 通过 Stream 进入 StreamOS 以及其他 Linux 发行版。它无需任何额外的成本,所以那些已经个人电脑建立的游戏的人可以很容易在 Linux 上安装它,并且运行良好。 + +[更多 Destructoid](http://api.viglink.com/api/click?format=go&jsonp=vglnk_145580435418216&key=0a7039c08493c7c51b759e3d13019dbe&libId=iksc5hc8010113at000DL3yrsuvp7&loc=http%3A%2F%2Fwww.infoworld.com%2Farticle%2F3033059%2Flinux%2Fwhat-do-linux-developers-think-of-git-and-github.html&v=1&out=http%3A%2F%2Fsteamcommunity.com%2Fgames%2F310950%2Fannouncements%2Fdetail%2F857177755595160250&ref=http%3A%2F%2Fwww.linux.com%2Fnews%2Fsoftware%2Fapplications%2F886008-what-do-linux-developers-think-of-git-and-github&title=What%20do%20Linux%20developers%20think%20of%20Git%20and%20GitHub%3F%20%7C%20InfoWorld&txt=Capcom%20has%20announced) + +你是否错过了摘要?检查 [Eye On Open home page](http://www.infoworld.com/blog/eye-on-open/) 来获得关于 Linux 和开源的最新的新闻。 + +------------------------------------------------------------------------------ + +via: http://www.infoworld.com/article/3033059/linux/what-do-linux-developers-think-of-git-and-github.html + +作者:[Jim Lynch][a] +译者:[mudongliang](https://github.com/mudongliang) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.infoworld.com/author/Jim-Lynch/ + diff --git a/translated/tech/20160303 Top 5 open source command shells for Linux.md b/translated/tech/20160303 Top 5 open source command shells for Linux.md deleted file mode 100644 index d40eb58b54..0000000000 --- a/translated/tech/20160303 Top 5 open source command shells for Linux.md +++ /dev/null @@ -1,86 +0,0 @@ -最牛的五个Linux开源command shell -=============================================== - -关键字: shell , Linux , bash , zsh , fish , ksh , tcsh , license - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/terminal_blue_smoke_command_line_0.jpg?itok=u2mRRqOa) - -这个世界上有两种Linux用户:敢于冒险的和态度谨慎的。 - -其中一类用户总是本能的去尝试任何能够戳中其痛点的新选择。他们尝试过不计其数的窗口管理器、系统发行版和几乎所有能找到的桌面插件。 - -另一类用户找到他们喜欢的东西后,会一直使用下去。他们往往喜欢所使用的系统发行版的默认选项。最先熟练掌握的文本编辑器会成为他们最钟爱的那一个。 - -作为一个使用桌面版和服务器版十五年之久的Linux用户,比起第一类来,我无疑属于第二类用户。我更倾向于使用现成的东西,如此一来,很多时候我就可以通过文档和示例方便地找到我所需要的使用案例。如果我决定选择使用非费标准的东西,这个切换过程一定会基于细致的研究,并且前提是来自挚友的大力推荐。 - -但这并不意味着我不喜欢尝试新事物并且查漏补失。所以最近一段时间,在我不假思索的使用了bash shell多年之后,决定尝试一下另外四个shell工具:ksh, tcsh, zsh, 和 fish. 这四个shell都可以通过我所以用的Fedora系统的默认库轻松安装,并且他们可能已经内置在你所使用的系统发行版当中了。 - -这里对每个选择都稍作介绍,并且阐述下它适合做为你的下一个Linux命令行解释器的原因所在。 - -### bash - -首先,我们回顾一下最为熟悉的一个。 [GNU Bash][1],又名 Bourne Again Shell,它是我这些年使用过的众多Linux发行版的默认选择。它最初发布于1989年,并且轻松成长为Linux世界中使用最广泛的shell,甚至常见于其他一些类Unix系统当中。 - -Bash是一个广受赞誉的shell,当你通过互联网寻找各种事情解决方法所需的文档时,总能够无一例外的发现这些文档都默认你使用的是bash shell。但Bash也有一些缺点存在,如果你写过Bash脚本就会发现我们写的代码总是得比真正所需要的多那么几行。这并不是说有什么事情是它做不到的,而是说它读写起来并不总是那么直观,至少是不够优雅。 - -如上所述,基于其巨大的安装量,并且考虑到各类专业和非专业系统管理员已经适应了它的使用方式和独特之处,至少在将来一段时间内,bash或许会一直存在。 - -### ksh - -[KornShell][4],或许你对这个名字并不熟悉,但是你一定知道它的调用命令 ksh。这个替代性的shell于80年代起源于贝尔实验室,由David Korn所写。虽然最初是一个专有软件,但是后期版本是在[Eclipse Public 许可][5]下发布的。 - -ksh的拥趸们列出了他们觉得其优越的诸多理由,包括更好的循环语法,清晰的管道退出代码,更简单的方式来处理重复命令和关联数组。它能够模拟vi和emacs的许多行为,所以如果你是一个重度文本编辑器患者,它值得你一试。最后,我发现它虽然在高级脚本方面拥有不同的体验,但在基本输入方面与bash如出一辙。 - -### tcsh - -[Tcsh][6]衍生于csh(Berkely Unix C shell),并且可以追溯到早期的Unix和计算本身。 - -Tcsh最大的卖点在于它的脚本语言,对于熟悉C语言编程的人来说,看起来会非常亲切。Tcsh的脚本编写有人喜欢,有人憎恶。但是它也有其他的技术特色,包括可以为aliases添加参数,各种可能迎合你偏好的默认行为,包括tab自动完成和将tab完成的工作记录下来以备后查。 - -你可以在[BSD 许可][7]下找到tcsh。 - -### zsh - -[Zsh][8]是另外一个与bash和ksh有着相似之处的shell。产生于90年代初,zsh支持众多有用的新技术,包括拼写纠正,主题化,可命名的目录快捷键,在多个终端中分享命令历史信息和各种相对于original Bourne shell的轻微调整。 - -虽然部分需要遵照GPL许可,但zsh的代码和二进制文件可以在MIT-like许可下进行分发; 你可以在 [actual license][9] 中查看细节。 - -### fish - -之前我访问了[fish][10]的主页,当看到 “好了,这是一个为90年代而生的命令行shell” 这条略带调侃的介绍时(fish完成于2005年),我就意识到我会爱上这个交互友好的shell的。 - -Fish的作者提供了若干切换过来的理由,shell中所有的不太实用的调用都有点小幽默并且能戳中笑点。这些特性包括自动建议("Watch out, Netscape Navigator 4.0"),支持“惊人”的256色VGA调色,不过也有真正有用的特性,包括根据机器的man页面自动补全命令,清除脚本和基于web的配置。 - -Fish的许可主要基于第二版GPL,但有些部分是在其他许可下的。你可以查看资源库来了解[完整信息][11] - -*** - -如果你想要寻找关于每个选择确切不同之处的详尽纲要,[这个网站][12]应该可以帮到你。 - -我的立场到底是怎样的呢?好吧,最终我应该还是会重新投入bash的怀抱,因为对于大多数时间都在使用命令行交互的人来说,切换过程对于高级脚本能带来的好处微乎其微,并且我已经习惯于使用bash了。 - -但是我很庆幸做出了敞开大门并且尝试新选择的决定。我知道门外还有许许多多其他的东西。你尝试过哪些shell,更中意哪一个?请在评论里告诉我们。 - -本文来源: https://opensource.com/business/16/3/top-linux-shells - -作者:[Jason Baker][a] -译者:[mr-ping](https://github.com/mr-ping) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/jason-baker - -[1]: https://www.gnu.org/software/bash/ -[2]: http://mywiki.wooledge.org/BashPitfalls -[3]: http://www.gnu.org/licenses/gpl.html -[4]: http://www.kornshell.org/ -[5]: https://www.eclipse.org/legal/epl-v10.html -[6]: http://www.tcsh.org/Welcome -[7]: https://en.wikipedia.org/wiki/BSD_licenses -[8]: http://www.zsh.org/ -[9]: https://sourceforge.net/p/zsh/code/ci/master/tree/LICENCE -[10]: https://fishshell.com/ -[11]: https://github.com/fish-shell/fish-shell/blob/master/COPYING -[12]: http://hyperpolyglot.org/unix-shells - diff --git a/translated/tech/20160425 How to Use Awk to Print Fields and Columns in File.md b/translated/tech/20160425 How to Use Awk to Print Fields and Columns in File.md index 127cc061c1..94b914cd3d 100644 --- a/translated/tech/20160425 How to Use Awk to Print Fields and Columns in File.md +++ b/translated/tech/20160425 How to Use Awk to Print Fields and Columns in File.md @@ -1,21 +1,20 @@ -ictlyh Translating -How to Use Awk to Print Fields and Columns in File +如何使用 Awk 打印文件中的字段和列 =================================================== -In this part of our [Linux Awk command series][1], we shall have a look at one of the most important features of Awk, which is field editing. +在 [Linux Awk 命令系列介绍][1] 的这部分,我们来看一下 awk 最重要的功能之一,字段编辑。 -It is good to know that Awk automatically divides input lines provided to it into fields, and a field can be defined as a set of characters that are separated from other fields by an internal field separator. +首先我们要知道 Awk 会自动把输入的行切分为字段,字段可以定义为是一些字符集,这些字符集和其它字段被内部字段分隔符分离。 ![](http://www.tecmint.com/wp-content/uploads/2016/04/Awk-Print-Fields-and-Columns.png) ->Awk Print Fields and Columns +>Awk 输出字段和列 -If you are familiar with the Unix/Linux or do [bash shell programming][2], then you should know what internal field separator (IFS) variable is. The default IFS in Awk are tab and space. +如果你熟悉 Unix/Linux 或者懂得 [bash shell 编程][2],那么你也应该知道内部字段分隔符(IFS)变量。Awk 默认的 IFS 是 tab 和空格。 -This is how the idea of field separation works in Awk: when it encounters an input line, according to the IFS defined, the first set of characters is field one, which is accessed using $1, the second set of characters is field two, which is accessed using $2, the third set of characters is field three, which is accessed using $3 and so forth till the last set of character(s). +Awk 字段切分的工作原理如下:当获得一行输入时,根据定义的 IFS,第一个字符集是字段一,用 $1 表示,第二个字符集是字段二,用 $2 表示,第三个字符集是字段三,用 $3 表示,以此类推直到最后一个字符集。 -To understand this Awk field editing better, let us take a look at the examples below: +为了更好的理解 Awk 的字段编辑,让我们来看看下面的例子: -**Example 1**: I have created a text file called tecmintinfo.txt. +**事例 1:**: 我创建了一个名为 tecmintinfo.txt 的文件。 ``` # vi tecmintinfo.txt @@ -23,24 +22,23 @@ To understand this Awk field editing better, let us take a look at the examples ``` ![](http://www.tecmint.com/wp-content/uploads/2016/04/Create-File-in-Linux.png) ->Create File in Linux +>在 Linux 中创建文件 -Then from the command line, I try to print the first, second and third fields from the file tecmintinfo.txt using the command below: +然后在命令行中使用以下命令打印 tecmintinfo.txt 文件中的第一、第二和第三个字段。 ``` $ awk '//{print $1 $2 $3 }' tecmintinfo.txt TecMint.comisthe ``` +从上面的输出中你可以看到,三个字段中的第一个是按照定义的 IFS,也就是空格,打印的。 -From the output above, you can see that the characters from the first three fields are printed based on the IFS defined which is space: +- 字段一 “TecMint.com” 使用 $1 访问。 +- 字段二 “is” 通过 $2 访问。 +- 字段三 “the” 通过 $3 访问。 -- Field one which is “TecMint.com” is accessed using $1. -- Field two which is “is” is accessed using $2. -- Field three which is “the” is accessed using $3. +如果你注意打印的输出,可以看到字段值之间并没有分隔开,这是 print 默认的方式。 -If you have noticed in the printed output, the field values are not separated and this is how print behaves by default. - -To view the output clearly with space between the field values, you need to add (,) operator as follows: +为了在字段值之间加入空格,你需要像下面这样添加(,)分隔符: ``` $ awk '//{print $1, $2, $3; }' tecmintinfo.txt @@ -48,11 +46,11 @@ $ awk '//{print $1, $2, $3; }' tecmintinfo.txt TecMint.com is the ``` -One important thing to note and always remember is that the use of ($) in Awk is different from its use in shell scripting. +很重要而且必须牢记的一点是,Awk 中 ($) 的使用和在 shell 脚本中不一样。 -Under shell scripting ($) is used to access the value of variables while in Awk ($) it is used only when accessing the contents of a field but not for accessing the value of variables. +在 shell 脚本中 ($) 用于获取变量的值,而在 Awk 中 ($) 只用于获取一个字段的内容,而不能用于获取变量的值。 -**Example 2**: Let us take a look at one other example using a file which contains multiple lines called my_shoping.list. +**事例2**: 让我们再看一个使用多行文件 my_shoping.list 的例子。 ``` No Item_Name Unit_Price Quantity Price @@ -62,7 +60,7 @@ No Item_Name Unit_Price Quantity Price 4 Ethernet_Cables #30,000 4 #120,000 ``` -Say you wanted to only print Unit_Price of each item on the shopping list, you will need to run the command below: +假设你只想打印购物清单中每个物品的 Unit_Price,你需要允许下面的命令: ``` $ awk '//{print $2, $3 }' my_shopping.txt @@ -74,9 +72,9 @@ RAM_Chips #150,000 Ethernet_Cables #30,000 ``` -Awk also has a printf command that helps you to format your output is a nice way as you can see the above output is not clear enough. +Awk 也有一个 printf 命令,它能帮助你用更好的方式格式化输出,正如你可以看到上面的输出并不清晰。 -Using printf to format output of the Item_Name and Unit_Price: +使用 printf 格式化输出 Item_Name 和 Unit_Price: ``` $ awk '//{printf "%-10s %s\n",$2, $3 }' my_shopping.txt @@ -88,18 +86,18 @@ RAM_Chips #150,000 Ethernet_Cables #30,000 ``` -### Summary +### 总结 -Field editing is very important when using Awk to filter text or strings, it helps you get particular data in columns in a list. And always remember that the use of ($) operator in Awk is different from that in shell scripting. +使用 Awk 进行文本和字符串过滤时字段编辑功能非常重要,它能帮助你从列表中获取列的特定数据。同时需要记住 Awk 中 ($) 操作符和 shell 脚本中不一样。 -I hope the article was helpful to you and for any additional information required or questions, you can post a comment in the comment section. +我希望这篇文章能对你有所帮助,如果你需要获取其它信息或者有任何疑问,都可以在下面的评论框中告诉我们。 -------------------------------------------------------------------------------- via: http://www.tecmint.com/awk-print-fields-columns-with-space-separator/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+tecmint+%28Tecmint%3A+Linux+Howto%27s+Guide%29 作者:[Aaron Kili][a] -译者:[译者ID](https://github.com/译者ID) +译者:[ictlyh](https://github.com/ictlyh) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/translated/tech/20160601 Learn Python Control Flow and Loops to Write and Tune Shell Scripts – Part 2.md b/translated/tech/20160601 Learn Python Control Flow and Loops to Write and Tune Shell Scripts – Part 2.md new file mode 100644 index 0000000000..d7b6bf6c2e --- /dev/null +++ b/translated/tech/20160601 Learn Python Control Flow and Loops to Write and Tune Shell Scripts – Part 2.md @@ -0,0 +1,285 @@ +学习使用 python 控制流和循环来编写和执行 Shell 脚本 —— Part 2 +====================================================================================== + +在[Python series][1]之前的文章里,我们分享了 Python的一个简介,它的命令行 shell 和 IDLE(译者注:python 自带的一个IDE)。我们也演示了如何进行数值运算,如何用变量存储值,还有如何打印那些值到屏幕上。最后,我们通过一个练习示例讲解了面向对象编程中方法和属性概念。 + +![](http://www.tecmint.com/wp-content/uploads/2016/06/Write-Shell-Scripts-in-Python-Programming.png) +>在 Python 编程中写 Linux Shell 脚本 + +本篇中,我嫩会讨论控制流(根据用户输入的信息,计算的结果,或者一个变量的当前值选择不同的动作行为)和循环(自动重复执行任务),接着应用到我们目前所学东西中,编写一个简单的 shell 脚本,这个脚本会显示操作系统类型,主机名,内核发行版,版本号和机器硬件名字。 + +这个例子尽管很基础,但是会帮助我们证明,比起使用一些 bash 工具写 shell 脚本,我们可以使得用 Python OOP 的兼容特性来编写 shell 脚本会更简单些。 + +换句话说,我们想从这里出发 + +``` +# uname -snrvm +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/05/Check-Hostname-of-Linux.png) +> 检查 Linux 的主机号 + +到 + +![](http://www.tecmint.com/wp-content/uploads/2016/05/Check-Linux-Hostname-Using-Python-Script.png) +> 用 Python 脚本来检查 Linux 的主机号 + +或者 + +![](http://www.tecmint.com/wp-content/uploads/2016/05/Script-to-Check-Linux-System-Information.png) +> 用脚本检查 Linux 系统信息 + +看着不错,不是吗?那我们就挽起袖子,开干吧。 + +### Python 中的控制流 + +如我们刚说那样,控制流允许我们根据一个给定的条件,选择不同的输出结果。在 Python 中最简单的实现就是一个 if/else 语句。 + +基本语法是这样的: + +``` +if condition: + # action 1 +else: + # action 2 +``` + +当 condition 求值为真(true),下面的代码块就会被执行(`# action 1`代表的部分)。否则,else 下面的代码就会运行。 +condition 可以是任何表达式,只要可以求得值为真或者假。 + +举个例子: + +1. 1 < 3 # 真 + +2. firstName == "Gabriel" # 对 firstName 为 Gabriel 的人是真,对其他不叫 Gabriel 的人为假 + + - 在第一个例子中,我们比较了两个值,判断 1 是否小于 3。 + - 在第二个例子中,我们比较了 firstName(一个变量)与字符串 “Gabriel”,看在当前执行的位置,firstName 的值是否等于该字符串。 + - 条件和 else 表达式都必须带着一个冒号(:)。 + - 缩进在 Python 非常重要。同样缩进下的行被认为是相同的代码块。 + +请注意,if/else 表达式只是 Python 中许多控制流工具的一个而已。我们先在这里了解以下,后面会用在我们的脚本中。你可以在[官方文档][2]中学到更多工具。 + +### Python 中的循环 + +简单来说,一个循环就是一组指令或者表达式序列,可以按顺序一直执行,只要一个条件为真,或者在一个列表里一次执行一个条目。 + +Python 中最简单的循环,就是 for 循环迭代一个给定列表的元素,或者一个字符串从第一个字符开始到最后一个字符结束。 + +基本语句: + +``` +for x in example: + # do this +``` + +这里的 example 可以是一个列表或者一个字符串。如果是列表,变量 x 就代表列表中每个元素;如果是字符串,x 就代表字符串中每个字符。 + +``` +>>> rockBands = [] +>>> rockBands.append("Roxette") +>>> rockBands.append("Guns N' Roses") +>>> rockBands.append("U2") +>>> for x in rockBands: + print(x) +or +>>> firstName = "Gabriel" +>>> for x in firstName: + print(x) +``` + +上面例子的输出如下图所示: + +![](http://www.tecmint.com/wp-content/uploads/2016/05/Learn-Loops-in-Python.png) +>学习 Python 中的循环 + +### Python 模块 + +很明显,必须有个途径可以保存一系列的 Python 指令和表达式到文件里,然后需要的时候再取出来。 + +准确来说模块就是这样的。特别地,os 模块提供了一个接口到操作系统的底层,允许我们做许多通常在命令行下的操作。 + +没错,os 模块包含了许多方法和属性,可以用来调用,就如我们之前文章里讲解的那样。尽管如此,我们需要使用 import 关键词导入(或者叫包含)模块到开发环境里来: + +``` +>>> import os +``` + +我们来打印出当前的工作目录: + +``` +>>> os.getcwd() +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/05/Learn-Python-Modules.png) +>学习 Python 模块 + +现在,让我们把所有结合在一起(包括之前文章里讨论的概念),编写需要的脚本。 + +### Python 脚本 + +以一个声明开始一个脚本是个不错的想法,表明脚本的目的,发行所依据的证书,和一个修订历史列出所做的修改。尽管这主要是个人喜好,但这会让我们的工作看起来比较专业。 + +这里有个脚本,可以输出这篇文章最前面展示的那样。脚本做了大量的注释,为了让大家可以理解发生了什么。 + +在进行下一步之前,花点时间来理解它。注意,我们是如何使用一个 if/else 结构,判断每个字段标题的长度是否比字段本身的值还大。 + +基于这个结果,我们用空字符去填充一个字段标题和下一个之间的空格。同时,我们使用一定数量的短线作为字段标题与其值之间的分割符。 + +``` +#!/usr/bin/python3 +# Change the above line to #!/usr/bin/python if you don't have Python 3 installed + +# Script name: uname.py +# Purpose: Illustrate Python's OOP capabilities to write shell scripts more easily +# License: GPL v3 (http://www.gnu.org/licenses/gpl.html) + +# Copyright (C) 2016 Gabriel Alejandro Cánepa +# ​Facebook / Skype / G+ / Twitter / Github: gacanepa +# Email: gacanepa (at) gmail (dot) com + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# REVISION HISTORY +# DATE VERSION AUTHOR CHANGE DESCRIPTION +# ---------- ------- -------------- +# 2016-05-28 1.0 Gabriel Cánepa Initial version + +# Import the os module +import os + +# Assign the output of os.uname() to the the systemInfo variable +# os.uname() returns a 5-string tuple (sysname, nodename, release, version, machine) +# Documentation: https://docs.python.org/3.2/library/os.html#module-os +systemInfo = os.uname() + +# This is a fixed array with the desired captions in the script output +headers = ["Operating system","Hostname","Release","Version","Machine"] + +# Initial value of the index variable. It is used to define the +# index of both systemInfo and headers in each step of the iteration. +index = 0 + +# Initial value of the caption variable. +caption = "" + +# Initial value of the values variable +values = "" + +# Initial value of the separators variable +separators = "" + +# Start of the loop +for item in systemInfo: + if len(item) < len(headers[index]): + # A string containing dashes to the length of item[index] or headers[index] + # To repeat a character(s), enclose it within quotes followed + # by the star sign (*) and the desired number of times. + separators = separators + "-" * len(headers[index]) + " " + caption = caption + headers[index] + " " + values = values + systemInfo[index] + " " * (len(headers[index]) - len(item)) + " " + else: + separators = separators + "-" * len(item) + " " + caption = caption + headers[index] + " " * (len(item) - len(headers[index]) + 1) + values = values + item + " " + # Increment the value of index by 1 + index = index + 1 +# End of the loop + +# Print the variable named caption converted to uppercase +print(caption.upper()) + +# Print separators +print(separators) + +# Print values (items in systemInfo) +print(values) + +# INSTRUCTIONS: +# 1) Save the script as uname.py (or another name of your choosing) and give it execute permissions: +# chmod +x uname.py +# 2) Execute it: +# ./uname.py +``` + +如果你已经保存上面的脚本到一个文件里,给文件执行权限,并且运行它,像代码底部描述的那样: + +``` +# chmod +x uname.py +# ./uname.py +``` + +如果试图运行脚本时,你得到了如下的错误: + +``` +-bash: ./uname.py: /usr/bin/python3: bad interpreter: No such file or directory +``` + +这意味着你没有安装 Python3。如果那样的话,你要么安装 Python3 的包,要么替换解释器那行(如果你跟着下面的步骤去更新 Python 执行文件的软连接,如之前文章里概述的那样,要特别注意并且非常小心): + +``` +#!/usr/bin/python3 +``` + +为 + +``` +#!/usr/bin/python +``` + +这样会导致使用安装好的 Python 2 版本去执行该脚本。 + +**注意**: 该脚本在 Python 2.x 与 Pyton 3.x 上都测试成功过了。 + +尽管比较粗糙,你可以认为该脚本就是一个 Python 模块。这意味着你可以在 IDLE 中打开它(File → Open… → Select file): + +![](http://www.tecmint.com/wp-content/uploads/2016/05/Open-Python-in-IDLE.png) +>在 IDLE 中打开 Python + +一个包含有文件内容的新窗口就会打开。然后执行 Run → Run module(或者按 F5)。脚本的输出就会在原 Shell 里显示出来: + +![](http://www.tecmint.com/wp-content/uploads/2016/05/Run-Python-Script.png) +>执行 Python 脚本 + +如果你想纯粹用 bash 写一个脚本,也获得同样的结果,你可能需要结合使用 [awk][3],[sed][4],并且借助复杂的方法来存储与获得列表中的元素(忘了提醒使用 tr 命令将小写字母转为大写) + +另外,Python 在所有的 Linux 系统版本中集成了至少一个 Python 版本(2.x 或者 3.x,或者两者都有)。你还需要依赖 shell 去完成同样的目标吗,那样你可能会为不同的 shell 编写不同的版本。 + +这里演示了面向对象编程的特性,会成为一个系统管理员得力的助手。 + +**注意**:你可以在我的 Github 仓库里获得 [这个 python 脚本][5](或者其他的)。 + +### 总结 + +这篇文章里,我们讲解了 Python 中控制流,循环/迭代,和模块的概念。我们也演示了如何利用 Python 中 OOP 的方法和属性,来简化复杂的 shell 脚本。 + +你有任何其他希望去验证的想法吗?开始吧,写出自己的 Python 脚本,如果有任何问题可以咨询我们。不必犹豫,在分割线下面留下评论,我们会尽快回复你。 + +-------------------------------------------------------------------------------- + +via: http://www.tecmint.com/learn-python-programming-to-write-linux-shell-scripts/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+tecmint+%28Tecmint%3A+Linux+Howto%27s+Guide%29 + +作者:[Gabriel Cánepa][a] +译者:[wi-cuckoo](https://github.com/wi-cuckoo) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.tecmint.com/author/gacanepa/ +[1]: http://www.tecmint.com/learn-python-programming-and-scripting-in-linux/ +[2]: http://please%20note%20that%20the%20if%20/%20else%20statement%20is%20only%20one%20of%20the%20many%20control%20flow%20tools%20available%20in%20Python.%20We%20reviewed%20it%20here%20since%20we%20will%20use%20it%20in%20our%20script%20later.%20You%20can%20learn%20more%20about%20the%20rest%20of%20the%20tools%20in%20the%20official%20docs. +[3]: http://www.tecmint.com/use-linux-awk-command-to-filter-text-string-in-files/ +[4]: http://www.tecmint.com/sed-command-to-create-edit-and-manipulate-files-in-linux/ +[5]: https://github.com/gacanepa/scripts/blob/master/python/uname.py + diff --git a/translated/tech/A newcomer's guide to navigating OpenStack Infrastructure.md b/translated/tech/A newcomer's guide to navigating OpenStack Infrastructure.md new file mode 100644 index 0000000000..b22d5e1fd5 --- /dev/null +++ b/translated/tech/A newcomer's guide to navigating OpenStack Infrastructure.md @@ -0,0 +1,65 @@ +translating by kylepeng93 +给学习OpenStack基础设施的新手的入门指南 +=========================================================== + +任何一个为OpenStack贡献源码的人会受到社区的欢迎,但是,对于一个发展趋近成熟并且快速迭代的开源社区而言,能够拥有一个新手指南并不是 +件坏事。在奥斯汀举办的OpenStack峰会上,[Paul Belanger][1] (红帽公司), [Elizabeth K. Joseph][2] (HPE公司),和[Christopher Aedo][3] (IBM公司)将会就针对新人的OpenStack基础设施作一场专门的会谈。在这次采访中,他们将会提供一些建议和资源来帮助新人成为OpenStack贡献者中的一员。 +![](https://opensource.com/sites/default/files/images/life/Interview%20banner%20Q%26A.png) + +**你在谈话中表示你将“投入全部身心于基础设施并解释你需要知道的有关于维持OpenStack正常工作的系统的每一件事情”。这是一个持续了40分钟的的艰巨任务。那么,对于学习OpenStack基础设施的新手来说最需要知道那些事情呢?** +**Elizabeth K. Joseph (EKJ)**: 我们没有为OpenStack使用GitHub这种提交补丁的方式,这是因为这样做会对新手造成巨大的困扰,尽管由于历史原因我们还是保留了所有原先就在GitHub上的所有库的镜像。相反,我们使用了一种完全开源的复查形式,并通过OpenStack基础设施团队来持续的维持系统集成(CI)。相关的,自从我们使用了CI系统,每一个提交给OpenStack的改变都会在被合并之前进行测试。 +**Paul Belanger (PB)**: 这个项目中的大多数都是富有激情的人,因此当你提交的补丁被某个人否定时不要感到沮丧。 +**Christopher Aedo (CA)**:社区很想帮助你取得成功,因此不要害怕提问或者寻求更多的那些能够促进你理解某些事物的引导者。 + +### 在你的讲话中,对于一些你无法涉及到的方面,你会向新手推荐哪些在线资源来让他们更加容易入门? +**PB**:当然是我们的[OpenStack项目基础设施文档][5]。我们已经花了足够大的努力来尽可能让这些文档能够随时保持最新状态。我们对每个运行OpenStack项目并投入使用的系统都有制作专门的页面来进行说明。甚至于连OpenStack云基础设施团队也即将上线。 + +**EKJ**:我对于将基础设施文档作为新手入门教程这件事上的观点和Paul是一致的,另外,我们十分乐意看到来自那些folk了我们项目的学习者提交上来的补丁。我们通常不会意识到我们忽略了文档中的某些内容,除非它们恰好被人问起。因此,阅读,学习,然后帮助我们修补这些知识上的漏洞。你可以在[OpenStack基础设施邮件清单]提出你的问题,或者在我们位于FreeNode上的#OpenStack-infra的IRC专栏发起你的提问。 +**CA**:我喜欢[这个详细的发布][7],它是由Ian Wienand写的一篇关于构建图片的文章。 +### "gotchas" 会是OpenStack新的代码贡献者苦苦寻找的吗? +**EKJ**:向项目作出贡献并不仅仅是提交新的代码和新的特性;OpenStack社区高度重视代码复查。如果你想要别人查看你的补丁,那你最好先看看其他人是如何做的,然后参考他们的风格,最后一步布做到你也能够向其他人一样提交清晰且结构分明的代码补丁。你越是能让你的同伴了解你的工作并知道你正在做的复查,那他们也就更有可能形成及时复查你的代码的风格。 +**CA**:我看到过大量的新手在面对Gerrit时受挫,阅读开发者引导中的[开发者工作步骤][9]时,可能只是将他通读了一遍。如果你没有经常使用Gerrit,那你最初对它的感觉可能是困惑和无力的。但是,如果你随后做了一些代码复查的工作,那么你马上就能轻松应对它。同样,我是IRC的忠实粉丝。它可能是一个获得帮助的好地方,但是,你最好保持一个长期保留的状态,这样,尽管你在某个时候没有出现,人们也可以回答你的问题。(阅读[IRC,开源界的成功秘诀][10]。)你不必总是在线,但是你最好能够轻松的在一个通道中进行回滚操作,以此来跟上最新的动态,这种能力非常重要。 +**PB**:我同意Elizabeth和Chris—Gerrit关于寻求何种方式来学习的观点。每个开发人员所作出的努力都将让社区变得更加美好。你不仅仅要提交代码给别人去复查,同时,你也要能够复查其他人的代码。留意Gerrit的用户接口,你可能一时会变的很疑惑。我推荐新手去尝试[Gertty][11],它是一个基于控制台的终端接口,用于Gerrit代码复查系统,而它恰好也是OpenStack基础设施所驱动的一个项目。 +### 你对于OpenStack新手如何通过网络与其他贡献者交流方面有什么好的建议? +**PB**:对我来说,是通过IRC以及在Freenode上参加#OpenStack-infra专栏([IRC logs][12]).这专栏上面有很多对新手来说很有价值的资源。你可以看到OpenStack项目日复一日的运作情况,同时,一旦你知道了OpenStack项目的工作原理,你将更好的知道如何为OpenStack的未来发展作出贡献。 +**CA**:我想要为IRC再次说明一点,在IRC上保持一整天的在线记录对我来说有非常重大的意义,因为我会感觉到被重视并且时刻保持连接。这也是一种非常好的获得帮助的方式,特别是当你卡在了项目中出现的某一个难题的时候,而在专栏中,总会有一些人很乐意为你解决问题。 +**EKJ**:[OpenStack开发邮件列表][13]对于能够时刻查看到你所致力于的OpenStack项目的最新情况是非常重要的。因此,我推荐一定要订阅它。邮件列表使用课题标签来区分项目,因此你可以设置你的邮件客户端来使用它,并且集中精力于你所关心的项目。除了在线资源之外,全世界范围内也成立了一些OpenStack小组,他们被用来为OpenStack的用户和贡献者提供服务。这些小组可能会定期举行座谈和针对OpenStack主要贡献者的一些活动。你可以在MeetUp.com上搜素你所在地域的贡献者活动聚会,或者在[groups.openstack.org]上查看你所在的地域是否存在OpenStack小组。最后,还有一个每六个月举办一次的OpenStack峰会,这个峰会上会作一些关于基础设施的演说。当前状态下,这个峰会包含了用户会议和开发者会议,会议内容都是和OpenStack相关的东西,包括它的过去,现在和未来。 +### OpenStack需要在那些方面得到提升来让新手更加容易学会并掌握? +**PB**: 我认为我们的[account-setup][16]过程对于新的贡献者已经做的比较容易了,特别是教他们如何提交他们的第一个补丁。真正参与到OpenStack开发者模式的过程是需要花费很大的努力的,可能对于开发者来说已经显得非常多了;然而,一旦融入进去了,这个模式将会运转的十分高效和令人满意。 +**CA**: 我们拥有一个由专业开发者组成的社区,而且我们的关注点都是发展OpenStack本身,同时,我们致力于让用户付出更小的代价去使用OpenStack云基础设施平台。我们需要发掘更多的应用开发者,并且鼓励更多的人去开发能在OpenStack云上完美运行的云应用程序,我们还鼓励他们在[社区App目录]上去贡献那些由他们开发的app。我们可以通过提升我们的API标准和保证我们不同的库(比如libcloud,phpopencloud已经其他一些库),并让他们持续的为开发者提供可信赖的支持来实现这一目标。还有一点就是通过倡导更多的OpenStack黑客加入进来。所有的这些事情都可以降低新人的学习门槛,这样也能引导他们与这个社区之间的关系更加紧密。y. +**EKJ**: 我已经致力于开源软件很多年了。但是,对于大量的OpenStack开发者而言,这是一个他们每个人都在从事的第一个开源项目。我发现他们之前使用私有软件的背景并没有为他们塑造开源的观念和方法论,还有在开源项目中需要具备的合作技巧。我乐于看到我们能够让那些曾经一直在使用私有软件工作的人能够真正的明白他们在开源如软件社区所从事的事情的巨大价值。 +### 我认为2016年对于开源Haiku的进一步增长是具有重大意义的一年。通过Haiku来向新手解释OpenStack。 +**PB**: 如果你喜欢自由软件,你可以向OpenStack提交你的第一个补丁。 +**CA**: 在不久的未来,OpenStack将以统治世界的姿态让这个世界变得更好。 +**EKJ**: OpenStack是一个可以免费部署在你的服务器上面并且运行你自己的云的一个软件。 +*Paul,Elizabeth和Christopher将会在4月25号星期一上午11:15于奥斯汀举办的OpenStack峰会上进行演说。 + +------------------------------------------------------------------------------ + +via: https://opensource.com/business/16/4/interview-openstack-infrastructure-beginners + +作者:[linux.com][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://rikkiendsley.com/ +[1]: https://twitter.com/pabelanger +[2]: https://twitter.com/pleia2 +[3]: https://twitter.com/docaedo +[4]: https://www.openstack.org/summit/austin-2016/summit-schedule/events/7337 +[5]: http://docs.openstack.org/infra/system-config/ +[6]: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-infra +[7]: https://www.technovelty.org/openstack/image-building-in-openstack-ci.html +[8]: https://code.google.com/p/gerrit/ +[9]: http://docs.openstack.org/infra/manual/developers.html#development-workflow +[10]: https://developer.ibm.com/opentech/2015/12/20/irc-the-secret-to-success-in-open-source/ +[11]: https://pypi.python.org/pypi/gertty +[12]: http://eavesdrop.openstack.org/irclogs/%23openstack-infra/ +[13]: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev +[14]: https://groups.openstack.org/ +[15]: https://www.openstack.org/summit/ +[16]: http://docs.openstack.org/infra/manual/developers.html#account-setup +[17]: https://apps.openstack.org/ +[18]: https://www.openstack.org/summit/austin-2016/summit-schedule/events/7337 diff --git a/translated/tech/awk/Part 1 - How to Use Awk and Regular Expressions to Filter Text or String in Files.md b/translated/tech/awk/Part 1 - How to Use Awk and Regular Expressions to Filter Text or String in Files.md new file mode 100644 index 0000000000..791c349f56 --- /dev/null +++ b/translated/tech/awk/Part 1 - How to Use Awk and Regular Expressions to Filter Text or String in Files.md @@ -0,0 +1,212 @@ +如何使用Awk和正则表达式过滤文本或文件中的字符串 +============================================================================= + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Linux-Awk-Command-Examples.png) + +当我们在 Unix/Linux 下使用特定的命令从字符串或文件中读取或编辑文本时,我们经常会尝试过滤输出以得到感兴趣的部分。这时正则表达式就派上用场了。 + +### 什么是正则表达式? + +正则表达式可以定义为代表若干个字符序列的字符串。它最重要的功能就是它允许你过滤一条命令或一个文件的输出,编辑文本或配置等文件的一部分。 + +### 正则表达式的特点 + +正则表达式由以下内容组合而成: + +- 普通的字符,例如空格、下划线、A-Z、a-z、0-9。 +- 可以扩展为普通字符的元字符,它们包括: + - `(.)` 它匹配除了换行符外的任何单个字符。 + - `(*)` 它匹配零个或多个在其之前的立即字符。 + - `[ character(s) ]` 它匹配任何由 character(s) 指定的一个字符,你可以使用连字符(-)代表字符区间,例如 [a-f]、[1-5]等。 + - `^` 它匹配文件中一行的开头。 + - `$` 它匹配文件中一行的结尾。 + - `\` 这是一个转义字符。 + +你必须使用类似 awk 这样的文本过滤工具来过滤文本。你还可以把 awk 当作一个用于自身的编程语言。但由于这个指南的适用范围是关于使用 awk 的,我会按照一个简单的命令行过滤工具来介绍它。 + +awk 的一般语法如下: + +``` +# awk 'script' filename +``` + +此处 `'script'` 是一个由 awk 使用并应用于 filename 的命令集合。 + +它通过读取文件中的给定的一行,复制该行的内容并在该行上执行脚本的方式工作。这个过程会在该文件中的所有行上重复。 + +该脚本 `'script'` 中内容的格式是 `'/pattern/ action'`,其中 `pattern` 是一个正则表达式,而 `action` 是当 awk 在该行中找到此模式时应当执行的动作。 + +### 如何在 Linux 中使用 Awk 过滤工具 + +在下面的例子中,我们将聚焦于之前讨论过的元字符。 + +#### 一个使用 awk 的简单示例: + +下面的例子打印文件 /etc/hosts 中的所有行,因为没有指定任何的模式。 + +``` +# awk '//{print}'/etc/hosts +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Awk-Command-Example.gif) +>Awk 打印文件中的所有行 + +#### 结合模式使用 Awk + +在下面的示例中,指定了模式 `localhost`,因此 awk 将匹配文件 `/etc/hosts` 中有 `localhost` 的那些行。 + +``` +# awk '/localhost/{print}' /etc/hosts +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-Command-with-Pattern.gif) +>Awk 打印文件中匹配模式的行 + +#### 在 Awk 模式中使用通配符 (.) + +在下面的例子中,符号 `(.)` 将匹配包含 loc、localhost、localnet 的字符串。 + +这里的意思是匹配 *** l 一些单个字符 c ***。 + +``` +# awk '/l.c/{print}' /etc/hosts +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-with-Wild-Cards.gif) +>使用 Awk 打印文件中匹配模式的字符串 + +#### 在 Awk 模式中使用字符 (*) + +在下面的例子中,将匹配包含 localhost、localnet、lines, capable 的字符串。 + +``` +# awk '/l*c/{print}' /etc/localhost +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Match-Strings-in-File.gif) +>使用 Awk 匹配文件中的字符串 + +你可能也意识到 `(*)` 将会尝试匹配它可能检测到的最长的匹配。 + +让我们看一看可以证明这一点的例子,正则表达式 `t*t` 的意思是在下面的行中匹配以 `t` 开始和 `t` 结束的字符串: + +``` +this is tecmint, where you get the best good tutorials, how to's, guides, tecmint. +``` + +当你使用模式 `/t*t/` 时,会得到如下可能的结果: + +``` +this is t +this is tecmint +this is tecmint, where you get t +this is tecmint, where you get the best good t +this is tecmint, where you get the best good tutorials, how t +this is tecmint, where you get the best good tutorials, how tos, guides, t +this is tecmint, where you get the best good tutorials, how tos, guides, tecmint +``` + +在 `/t*t/` 中的通配符 `(*)` 将使得 awk 选择匹配的最后一项: + +``` +this is tecmint, where you get the best good tutorials, how to's, guides, tecmint +``` + +#### 结合集合 [ character(s) ] 使用 Awk + +以集合 [al1] 为例,awk 将匹配文件 /etc/hosts 中所有包含字符 a 或 l 或 1 的字符串。 + +``` +# awk '/[al1]/{print}' /etc/hosts +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Print-Matching-Character.gif) +>使用 Awk 打印文件中匹配的字符 + +下一个例子匹配以 `K` 或 `k` 开始头,后面跟着一个 `T` 的字符串: + +``` +# awk '/[Kk]T/{print}' /etc/hosts +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Print-Matched-String-in-File.gif) +>使用 Awk 打印文件中匹配的字符 + +#### 以范围的方式指定字符 + +awk 所能理解的字符: + +- `[0-9]` 代表一个单独的数字 +- `[a-z]` 代表一个单独的小写字母 +- `[A-Z]` 代表一个单独的大写字母 +- `[a-zA-Z]` 代表一个单独的字母 +- `[a-zA-Z 0-9]` 代表一个单独的字母或数字 + +让我们看看下面的例子: + +``` +# awk '/[0-9]/{print}' /etc/hosts +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-To-Print-Matching-Numbers-in-File.gif) +>使用 Awk 打印文件中匹配的数字 + +在上面的例子中,文件 /etc/hosts 中的所有行都至少包含一个单独的数字 [0-9]。 + +#### 结合元字符 (\^) 使用 Awk + +在下面的例子中,它匹配所有以给定模式开头的行: + +``` +# awk '/^fe/{print}' /etc/hosts +# awk '/^ff/{print}' /etc/hosts +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Print-All-Matching-Lines-with-Pattern.gif) +>使用 Awk 打印与模式匹配的行 + +#### 结合元字符 ($) 使用 Awk + +它将匹配所有以给定模式结尾的行: + +``` +# awk '/ab$/{print}' /etc/hosts +# awk '/ost$/{print}' /etc/hosts +# awk '/rs$/{print}' /etc/hosts +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Print-Given-Pattern-String.gif) +>使用 Awk 打印与模式匹配的字符串 + +#### 结合转义字符 (\\) 使用 Awk + +它允许你将该转义字符后面的字符作为文字,即理解为其字面的意思。 + +在下面的例子中,第一个命令打印出文件中的所有行,第二个命令中我想匹配具有 $25.00 的一行,但我并未使用转义字符,因而没有打印出任何内容。 + +第三个命令是正确的,因为一个这里使用了一个转义字符以转义 $,以将其识别为 '$'(而非元字符)。 + +``` +# awk '//{print}' deals.txt +# awk '/$25.00/{print}' deals.txt +# awk '/\$25.00/{print}' deals.txt +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-with-Escape-Character.gif) +>结合转义字符使用 Awk + +### 总结 + +以上内容并不是 Awk 命令用做过滤工具的全部,上述的示例均是 awk 的基础操作。在下面的章节中,我将进一步介绍如何使用 awk 的高级功能。感谢您的阅读,请在评论区贴出您的评论。 + +-------------------------------------------------------------------------------- + +via: http://www.tecmint.com/use-linux-awk-command-to-filter-text-string-in-files/ + +作者:[Aaron Kili][a] +译者:[wwy-hust](https://github.com/wwy-hust) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.tecmint.com/author/aaronkili/ diff --git a/translated/tech/awk/Part 3 - How to Use Awk to Filter Text or Strings Using Pattern Specific Actions.md b/translated/tech/awk/Part 3 - How to Use Awk to Filter Text or Strings Using Pattern Specific Actions.md new file mode 100644 index 0000000000..ef91e93575 --- /dev/null +++ b/translated/tech/awk/Part 3 - How to Use Awk to Filter Text or Strings Using Pattern Specific Actions.md @@ -0,0 +1,82 @@ +如何使用 Awk 来筛选文本或字符串 +========================================================================= + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Use-Awk-to-Filter-Text-or-Strings-Using-Pattern.png) + +作为 Awk 命令系列的第三部分,这次我们将看一看如何基于用户定义的特定模式来筛选文本或字符串。 + +在筛选文本时,有时你可能想根据某个给定的条件或使用一个特定的可被匹配的模式,去标记某个文件或数行字符串中的某几行。使用 Awk 来完成这个任务是非常容易的,这也正是 Awk 中可能对你有所帮助的几个特色之一。 + +让我们看一看下面这个例子,比方说你有一个写有你想要购买的食物的购物清单,其名称为 food_prices.list,它所含有的食物名称及相应的价格如下所示: + +``` +$ cat food_prices.list +No Item_Name Quantity Price +1 Mangoes 10 $2.45 +2 Apples 20 $1.50 +3 Bananas 5 $0.90 +4 Pineapples 10 $3.46 +5 Oranges 10 $0.78 +6 Tomatoes 5 $0.55 +7 Onions 5 $0.45 +``` + +然后,你想使用一个 `(*)` 符号去标记那些单价大于 $2 的食物,那么你可以通过运行下面的命令来达到此目的: + +``` +$ awk '/ *\$[2-9]\.[0-9][0-9] */ { print $1, $2, $3, $4, "*" ; } / *\$[0-1]\.[0-9][0-9] */ { print ; }' food_prices.list +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Filter-and-Print-Text-Using-Awk.gif) +>打印出单价大于 $2 的项目 + +从上面的输出你可以看到在含有 芒果(mangoes) 和 菠萝(pineapples) 的那行末尾都已经有了一个 `(*)` 标记。假如你检查它们的单价,你可以看到它们的单价的确超过了 $2 。 + +在这个例子中,我们已经使用了两个模式: + +- 第一个模式: `/ *\$[2-9]\.[0-9][0-9] */` 将会得到那些含有食物单价大于 $2 的行, +- 第二个模式: `/*\$[0-1]\.[0-9][0-9] */` 将查找那些食物单价小于 $2 的那些行。 + +上面的命令具体做了什么呢?这个文件有四个字段,当模式一匹配到含有食物单价大于 $2 的行时,它便会输出所有的四个字段并在该行末尾加上一个 `(*)` 符号来作为标记。 + +第二个模式只是简单地输出其他含有食物单价小于 $2 的行,因为它们出现在输入文件 food_prices.list 中。 + +这样你就可以使用模式来筛选出那些价格超过 $2 的食物项目,尽管上面的输出还有些问题,带有 `(*)` 符号的那些行并没有像其他行那样被格式化输出,这使得输出显得不够清晰。 + +我们在 Awk 系列的第二部分中也看到了同样的问题,但我们可以使用下面的两种方式来解决: + +1. 可以像下面这样使用 printf 命令,但这样使用又长又无聊: + +``` +$ awk '/ *\$[2-9]\.[0-9][0-9] */ { printf "%-10s %-10s %-10s %-10s\n", $1, $2, $3, $4 "*" ; } / *\$[0-1]\.[0-9][0-9] */ { printf "%-10s %-10s %-10s %-10s\n", $1, $2, $3, $4; }' food_prices.list +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Filter-and-Print-Items-Using-Awk-and-Printf.gif) +>使用 Awk 和 Printf 来筛选和输出项目 + +2. 使用 `$0` 字段。Awk 使用变量 **0** 来存储整个输入行。对于上面的问题,这种方式非常方便,并且它还简单、快速: + +``` +$ awk '/ *\$[2-9]\.[0-9][0-9] */ { print $0 "*" ; } / *\$[0-1]\.[0-9][0-9] */ { print ; }' food_prices.list +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/04/Filter-and-Print-Items-Using-Awk-and-Variable.gif) +>使用 Awk 和变量来筛选和输出项目 + +### 结论 + +这就是全部内容了,使用 Awk 命令你便可以通过几种简单的方法去利用模式匹配来筛选文本,帮助你在一个文件中对文本或字符串的某些行做标记。 + +希望这篇文章对你有所帮助。记得阅读这个系列的下一部分,我们将关注在 awk 工具中使用比较运算符。 + +-------------------------------------------------------------------------------- + +via: http://www.tecmint.com/awk-filter-text-or-string-using-patterns/ + +作者:[Aaron Kili][a] +译者:[FSSlc](https://github.com/FSSlc) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.tecmint.com/author/aaronkili/ \ No newline at end of file diff --git a/translated/tech/awk/Part 6 - How to Use ‘next’ Command with Awk in Linux.md b/translated/tech/awk/Part 6 - How to Use ‘next’ Command with Awk in Linux.md new file mode 100644 index 0000000000..8ead60bd44 --- /dev/null +++ b/translated/tech/awk/Part 6 - How to Use ‘next’ Command with Awk in Linux.md @@ -0,0 +1,76 @@ + +如何使用AWK的‘next’命令 +============================================= + +![](http://www.tecmint.com/wp-content/uploads/2016/06/Use-next-Command-with-Awk-in-Linux.png) + +在Awk 系列的第六章, 我们来看一下`next`命令 ,它告诉 Awk 跳过你所提供的表达式而是读取下一个输入行. +`next` 命令帮助你阻止运行多余的步骤. + +要明白它是如何工作的, 让我们来分析一下food_list.txt它看起来像这样 : + +``` +Food List Items +No Item_Name Price Quantity +1 Mangoes $3.45 5 +2 Apples $2.45 25 +3 Pineapples $4.45 55 +4 Tomatoes $3.45 25 +5 Onions $1.45 15 +6 Bananas $3.45 30 +``` + +运行下面的命令,它将在每个食物数量小于或者等于20的行后面标一个星号: + +``` +# awk '$4 <= 20 { printf "%s\t%s\n", $0,"*" ; } $4 > 20 { print $0 ;} ' food_list.txt + +No Item_Name Price Quantity +1 Mangoes $3.45 5 * +2 Apples $2.45 25 +3 Pineapples $4.45 55 +4 Tomatoes $3.45 25 +5 Onions $1.45 15 * +6 Bananas $3.45 30 +``` + +上面的命令实际运行如下: + +- 首先, 它用`$4 <= 20`表达式检查每个输入行的第四列是否小于或者等于20,如果满足条件, 它将在末尾打一个星号 `(*)` . +- 接着, 它用`$4 > 20`表达式检查每个输入行的第四列是否大于20,如果满足条件,显示出来. + +但是这里有一个问题, 当第一个表达式用`{ printf "%s\t%s\n", $0,"**" ; }`命令进行标注的时候在同样的步骤第二个表达式也进行了判断这样就浪费了时间. + +因此当我们已经用第一个表达式打印标志行的时候就不在需要用第二个表达式`$4 > 20`再次打印. + +要处理这个问题, 我们需要用到`next` 命令: + +``` +# awk '$4 <= 20 { printf "%s\t%s\n", $0,"*" ; next; } $4 > 20 { print $0 ;} ' food_list.txt + +No Item_Name Price Quantity +1 Mangoes $3.45 5 * +2 Apples $2.45 25 +3 Pineapples $4.45 55 +4 Tomatoes $3.45 25 +5 Onions $1.45 15 * +6 Bananas $3.45 30 +``` + +当输入行用`$4 <= 20` `{ printf "%s\t%s\n", $0,"*" ; next ; }`命令打印以后,`next`命令 将跳过第二个`$4 > 20` `{ print $0 ;}`表达式, 继续判断下一个输入行,而不是浪费时间继续判断一下是不是当前输入行还大于20. + +next命令在编写高效的命令脚本时候是非常重要的, 它可以很大的提高脚本速度. 下面我们准备来学习Awk的下一个系列了. + +希望这篇文章对你有帮助,你可以给我们留言. + +-------------------------------------------------------------------------------- + +via: http://www.tecmint.com/use-next-command-with-awk-in-linux/ + +作者:[Aaron Kili][a] +译者:[kokialoves](https://github.com/kokialoves) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.tecmint.com/author/aaronkili/ diff --git a/translated/tech/awk/Part 7 - How to Read Awk Input from STDIN in Linux.md b/translated/tech/awk/Part 7 - How to Read Awk Input from STDIN in Linux.md new file mode 100644 index 0000000000..0d0d499d00 --- /dev/null +++ b/translated/tech/awk/Part 7 - How to Read Awk Input from STDIN in Linux.md @@ -0,0 +1,76 @@ + + +在 Linux 上怎么读取标准输入(STDIN)作为 Awk 的输入 +============================================ + +![](http://www.tecmint.com/wp-content/uploads/2016/06/Read-Awk-Input-from-STDIN.png) + + +在 Awk 工具系列的前几节,我们看到大多数操作都是从一个文件或多个文件读取输入,或者你想要把标准输入作为 Awk 的输入. +在 Awk 系列的第7节中,我们将会看到几个例子,这些例子都是关于你可以筛选其他命令的输出代替从一个文件读取输入作为 awk 的输入. + + +我们开始使用 [dir utility][1] , dir 命令和 [ls 命令][2] 相似,在第一个例子下面,我们使用 'dir -l' 命令的输出作为 Awk 命令的输入,这样就可以打印出文件拥有者的用户名,所属组组名以及在当前路径下他/她拥有的文件. +``` +# dir -l | awk '{print $3, $4, $9;}' +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/06/List-Files-Owned-By-User-in-Directory.png) +>列出当前路径下的用户文件 + + +看另一个例子,我们 [使用 awk 表达式][3] ,在这里,我们想要在 awk 命令里使用一个表达式筛选出字符串,通过这样来打印出 root 用户的文件.命令如下: +``` +# dir -l | awk '$3=="root" {print $1,$3,$4, $9;} ' +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/06/List-Files-Owned-by-Root-User.png) +>列出 root 用户的文件 + + +上面的命令包含了 '(==)' 来进行比较操作,这帮助我们在当前路径下筛选出 root 用户的文件.这种方法的实现是通过使用 '$3=="root"' 表达式. + +让我们再看另一个例子,我们使用一个 [awk 比较运算符][4] 来匹配一个确定的字符串. + + +现在,我们已经用了 [cat utility][5] 来浏览文件名为 tecmint_deals.txt 的文件内容,并且我们想要仅仅查看有字符串 Tech 的部分,所以我们会运行下列命令: +``` +# cat tecmint_deals.txt +# cat tecmint_deals.txt | awk '$4 ~ /tech/{print}' +# cat tecmint_deals.txt | awk '$4 ~ /Tech/{print}' +``` + +![](http://www.tecmint.com/wp-content/uploads/2016/06/Use-Comparison-Operator-to-Match-String.png) +>用 Awk 比较运算符匹配字符串 + + +在上面的例子中,我们已经用了参数为 `~ /匹配字符/` 的比较操作,但是上面的两个命令给我们展示了一些很重要的问题. + +当你运行带有 tech 字符串的命令时终端没有输出,因为在文件中没有 tech 这种字符串,但是运行带有 Tech 字符串的命令,你却会得到包含 Tech 的输出. + +所以你应该在进行这种比较操作的时候时刻注意这种问题,正如我们在上面看到的那样, awk 对大小写很敏感. + + +你可以一直使用另一个命令的输出作为 awk 命令的输入来代替从一个文件中读取输入,这就像我们在上面看到的那样简单. + + +希望这些例子足够简单可以使你理解 awk 的用法,如果你有任何问题,你可以在下面的评论区提问,记得查看 awk 系列接下来的章节内容,我们将关注 awk 的一些功能,比如变量,数字表达式以及赋值运算符. +-------------------------------------------------------------------------------- + +via: http://www.tecmint.com/read-awk-input-from-stdin-in-linux/ + +作者:[Aaron Kili][a] +译者:[vim-kakali](https://github.com/vim-kakali) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.tecmint.com/author/aaronkili/ +[1]: http://www.tecmint.com/linux-dir-command-usage-with-examples/ +[2]: http://www.tecmint.com/15-basic-ls-command-examples-in-linux/ +[3]: http://www.tecmint.com/combine-multiple-expressions-in-awk +[4]: http://www.tecmint.com/comparison-operators-in-awk +[5]: http://www.tecmint.com/13-basic-cat-command-examples-in-linux/ + + +