mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
8abf56321c
@ -1,22 +1,24 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Yufei-Yan)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-12379-1.html)
|
||||
[#]: subject: (Learn Shell Scripting for Free With These Resources [PDF, Video Courses and Interactive Websites])
|
||||
[#]: via: (https://itsfoss.com/shell-scripting-resources/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
通过这些资源免费学习 Shell 脚本编程——PDF,视频课程和互动网站
|
||||
学习 Shell 脚本编程的免费资源
|
||||
======
|
||||
|
||||
_**那么, 你想学习 shell 脚本编程吗?或者你想提升现有的 bash 知识?我收集了以下免费的资源来帮助你学习 shell 脚本编程。**_
|
||||
> 你想学习 shell 脚本编程吗?或者你想提升现有的 bash 知识?我收集了以下免费的资源来帮助你学习 shell 脚本编程。
|
||||
|
||||
(LCTT 译注:毫无疑问,这些都是英文的)
|
||||
|
||||
shell 是一个命令行解释器,它允许你输入命令并获得输出。当你在使用终端的时候,你就已经在看 shell 了。
|
||||
|
||||
是的,shell 是一个你可以和它进行交互的命令行界面,你可以通过它给操作系统某种指令。虽然有不同类型的 shell,**[bash][1]**(GNU Bourne-Again Shell)是在各 Linux 发行版中最流行的。
|
||||
是的,shell 是一个你可以和它进行交互的命令行界面,你可以通过它给操作系统某种指令。虽然有不同类型的 shell,但是 [bash][1](GNU Bourne-Again Shell)是在各 Linux 发行版中最流行的。
|
||||
|
||||
当谈到 shell 脚本编程的时候,也就意味着——用户希望使用脚本来执行多条命令来获得一个输出。
|
||||
当谈到 shell 脚本编程的时候,也就意味着 —— 用户希望使用脚本来执行多条命令来获得一个输出。
|
||||
|
||||
也许你需要学习 shell 脚本编程作为你的课程或者工作的一部分。了解 shell 脚本编程也可以帮助你在 Linux 中自动化某些重复的任务。
|
||||
|
||||
@ -28,107 +30,89 @@ shell 是一个命令行解释器,它允许你输入命令并获得输出。
|
||||
|
||||
还没在你的系统上安装 Linux?不用担心。有很多种方法[在 Windows 上使用 Linux 终端][3]。你也可以在某些情况下[使用在线 Linux 终端][4]来练习 shell 脚本编程。
|
||||
|
||||
#### 1\. 学习 Shell——互动网站
|
||||
#### 1、学习 Shell —— 互动网站
|
||||
|
||||
![][5]
|
||||
|
||||
如果你正在找一个互动网站来学习 shell 脚本编程,并且还可以在线试试,Learn Shell 是一个不错的起点。
|
||||
如果你正在找一个互动网站来学习 shell 脚本编程,并且还可以在线试试,“[学习 Shell][6]” 是一个不错的起点。
|
||||
|
||||
它涵盖了基础知识,并且也提供了一些高级的练习。通常,内容还是简明扼要的——因此,我建议你看看这个网站。
|
||||
它涵盖了基础知识,并且也提供了一些高级的练习。通常,内容还是简明扼要的 —— 因此,我建议你看看这个网站。
|
||||
|
||||
[Learn Shell][6]
|
||||
|
||||
#### 2\. Shell 脚本编程教程——门户网站
|
||||
#### 2、Shell 脚本编程教程 —— 门户网站
|
||||
|
||||
![][7]
|
||||
|
||||
Shell scripting tutorial 是一个完全专注于 shell 脚本编程的网站。你可以选择免费阅读其中的资源,也可以购买 PDF、实体书籍和电子书来支持他们。
|
||||
“[Shell 脚本编程教程][8]” 是一个完全专注于 shell 脚本编程的网站。你可以选择免费阅读其中的资源,也可以购买 PDF、实体书籍和电子书来支持他们。
|
||||
|
||||
当然,花钱买纸质的版本或者电子书不是强制的。但是,这些免费资源查看起来还是很方便的。
|
||||
|
||||
[Shell Scripting Tutorial][8]
|
||||
|
||||
#### 3\. Shell 脚本——Udemy(免费视频课程)
|
||||
#### 3、Udemy:Shell 脚本 —— 免费视频课程
|
||||
|
||||
![][9]
|
||||
|
||||
毫无疑问,[Udemy][10] 是最受欢迎的在线课程平台之一。而且,除了付费认证课程之外,它还提供了不包含证书的免费内容。
|
||||
|
||||
Shell Scripting 是 Udemy 上推荐度最高的免费课程之一。你不需要花费任何费用就可以注册这门课。
|
||||
“[Shell 脚本][11]” 是 Udemy 上推荐度最高的免费课程之一。你不需要花费任何费用就可以注册这门课。
|
||||
|
||||
[Shell Scripting – Udemy][11]
|
||||
|
||||
#### 4\. Bash Shell Scripting——Udemy(免费视频课程)
|
||||
#### 4、Udemy:Bash Shell 脚本编程 —— 免费视频课程
|
||||
|
||||
![][12]
|
||||
|
||||
Udemy 上另一个专注于 bash shell 脚本编程的有趣且免费的课程。与前面提到的课程相比,这个资源似乎更受欢迎。所以,你可以注册这门课,看看它都教些什么。
|
||||
Udemy 上另一个专注于 [bash shell 脚本编程][29]的有趣且免费的课程。与前面提到的课程相比,这个资源似乎更受欢迎。所以,你可以注册这门课,看看它都教些什么。
|
||||
|
||||
别忘了 Udemy 的免费课程不能提供证书。但是,它确实是一个让人印象深刻的免费 shell 脚本编程学习资源。
|
||||
|
||||
#### 5\. Bash Academy——互动游戏在线门户
|
||||
#### 5、Bash 研究院 —— 互动游戏在线门户
|
||||
|
||||
![][13]
|
||||
|
||||
顾名思义,Bash Academy 专注于向用户提供 bash shell 的教学。
|
||||
顾名思义,“[Bash 研究院][15]” 专注于向用户提供 bash shell 的教学。
|
||||
|
||||
尽管它没有很多的内容,它还是非常适合初学者和有一定经验的用户。不仅仅局限于指导——它也可以提供交互式的游戏来练习,不过目前已经不能用了。
|
||||
尽管它没有很多的内容,它还是非常适合初学者和有一定经验的用户。不仅仅局限于指导 —— 它也可以提供交互式的游戏来练习,不过目前已经不能用了。
|
||||
|
||||
因此,如果这个足够有趣,你可以去看看这个 [Github 页面][14],并且如果你愿意的话,还可以 fork 它并对现有资源进行改进。
|
||||
因此,如果这个足够有趣,你可以去看看这个 [Github 页面][14],并且如果你愿意的话,还可以复刻它并对现有资源进行改进。
|
||||
|
||||
[Bash Academy][15]
|
||||
|
||||
#### 6\. Bash Scripting LinkedIn Learning(免费视频课程)
|
||||
#### 6、LinkedIn:学习 Bash 脚本编程 —— 免费视频课程
|
||||
|
||||
![][16]
|
||||
|
||||
LinkedIn 提供了大量免费课程来帮助你提成技能,并且为更多工作做好准备。你还可以找到一些专注于 shell 脚本编程的课程,这些课程有助于重温基本技能或者这个过程中获得一些高级技能。
|
||||
|
||||
在这里,我提供一个 bash 脚本编程的课程链接,你还可以发现其他类似的免费课程。
|
||||
在这里,我提供一个 [学习 Bash 脚本编程][17] 的课程链接,你还可以发现其他类似的免费课程。
|
||||
|
||||
[Bash Scripting (LinkedIn Learning)][17]
|
||||
|
||||
#### 7\. Advanced Bash Scripting Guide (免费 PDF 书籍)
|
||||
#### 7、高级 Bash 脚本编程指南 —— 免费 PDF 书籍
|
||||
|
||||
![][18]
|
||||
|
||||
这是一个令人印象深刻的高级 bash 脚本编程指南,并且可以获得到它的 PDF 版本。这个 PDF 资源没有版权限制,是完全免费的。
|
||||
这是一个令人印象深刻的《[高级 Bash 脚本编程指南][19]》,并且可以免费获得到它的 PDF 版本。这个 PDF 资源没有版权限制,在公开领域是完全免费的。
|
||||
|
||||
尽管这个资源主要是提供高级的知识,通过参考这个 PDF 并且开始学习 shell 脚本编程,它还是很适合初学者的。
|
||||
|
||||
[Advanced Bash Scripting Guide [PDF]][19]
|
||||
|
||||
#### 8\. Bash Notes for Professionals(免费 PDF 书籍)
|
||||
#### 8、专业 Bash 笔记 —— 免费 PDF 书籍
|
||||
|
||||
![][20]
|
||||
|
||||
如果你已经对 Bash Shell 脚本编程比较熟悉或者只是想快速总结一下,那这是一个很好的参考。
|
||||
|
||||
这个可以免费下载的书有 100 多页,通过简单的描述和例子,这本书涵盖了各种各样的主题。
|
||||
这个《[专业 Bash 笔记][21]》可以免费下载的书有 100 多页,通过简单的描述和例子,这本书涵盖了各种各样的主题。
|
||||
|
||||
[下载 Bash Notes for Professional][21]
|
||||
|
||||
#### 9\. Tutorialspoint——门户网站
|
||||
#### 9、Tutorialspoint —— 门户网站
|
||||
|
||||
![][22]
|
||||
|
||||
Tutorialspoint 是一个非常流行的学习各种编程语言的门户网站。我想说这对于初学者学习基础知识非常好。
|
||||
“[Tutorialspoint][24]” 是一个非常流行的学习各种编程语言的门户网站。我想说这对于初学者学习基础知识非常好。
|
||||
|
||||
也许这不太适合作为一个详细的资源——但是他应该是不错的免费资源。
|
||||
也许这不太适合作为一个详细的资源——但是它应该是不错的免费资源。
|
||||
|
||||
[Tutorialspoint][24]
|
||||
|
||||
#### 10\. 旧金山城市学院在线笔记——门户网站
|
||||
#### 10、旧金山城市学院:在线笔记 —— 门户网站
|
||||
|
||||
![][25]
|
||||
|
||||
也许这不是最好的免费资源——但是如果你已经为学习 shell 脚本编程做好了探索每种资源的准备,为什么不看看旧金山城市学院的在线笔记呢?
|
||||
也许这不是最好的免费资源 —— 但是如果你已经为学习 shell 脚本编程做好了探索每种资源的准备,为什么不看看旧金山城市学院的 “[在线笔记][26]” 呢?
|
||||
|
||||
当我在网上随便搜索关于 shell 脚本编程的资源的时候,我偶然遇到到了这个资源。
|
||||
|
||||
同样需要注意的是,在线笔记可能会有点过时。但是,这应该还是一个值得探索的有趣资源。
|
||||
|
||||
[旧金山城市学院笔记][26]
|
||||
同样需要注意的是,这个在线笔记可能会有点过时。但是,这应该还是一个值得探索的有趣资源。
|
||||
|
||||
#### 荣誉奖: Linux 手册
|
||||
|
||||
@ -136,12 +120,13 @@ Tutorialspoint 是一个非常流行的学习各种编程语言的门户网站
|
||||
|
||||
不要忘记,bash 手册也应该是一个相当不错的免费资源,可以用它来查看命令和使用方法。
|
||||
|
||||
尽管他不是专门为你掌握 shell 脚本编程而量身打造的,它依然是一个你可以免费使用的重要网络资源。你可以选择访问在线手册,或者直接打开终端然后输入以下命令:
|
||||
尽管它不是专门为你掌握 shell 脚本编程而量身打造的,它依然是一个你可以免费使用的重要网络资源。你可以选择访问在线手册,或者直接打开终端然后输入以下命令:
|
||||
|
||||
```
|
||||
man bash
|
||||
```
|
||||
#### 总结
|
||||
|
||||
### 总结
|
||||
|
||||
有很多很受欢迎的付费资源,比如这些[最好的 Linux 书籍][28]。从网络上的一些免费资源开始学习 shell 脚本编程还是很方便的。
|
||||
|
||||
@ -156,7 +141,7 @@ via: https://itsfoss.com/shell-scripting-resources/
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[Yufei-Yan](https://github.com/Yufei-Yan)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@ -190,3 +175,4 @@ via: https://itsfoss.com/shell-scripting-resources/
|
||||
[26]: https://fog.ccsf.edu/~gboyd/cs160b/online/index.html
|
||||
[27]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/bash-linux-man-page.png?ssl=1
|
||||
[28]: https://itsfoss.com/best-linux-books/
|
||||
[29]: https://www.udemy.com/course/complete-bash-shell-scripting/
|
@ -1,12 +1,3 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (plutoid)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (50 Best Ubuntu Apps You Should Be Using Right Now)
|
||||
[#]: via: (https://itsfoss.com/best-ubuntu-apps/)
|
||||
[#]: author: (Abhishek Prakash)
|
||||
|
||||
50 Best Ubuntu Apps You Should Be Using Right Now
|
||||
======
|
||||
**Brief: A comprehensive list of best Ubuntu apps for all kind of users. These software will help you in getting a better experience with your Linux desktop.**
|
||||
|
@ -1,74 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( guevaraya)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Open source has room for everyone)
|
||||
[#]: via: (https://opensource.com/article/20/4/interview-Megan-Byrd-Sanicki)
|
||||
[#]: author: (Jay Barber https://opensource.com/users/jaybarber)
|
||||
|
||||
Open source has room for everyone
|
||||
======
|
||||
Learn how Megan Byrd-Sanicki, 2020 Women in Open Source Community Award
|
||||
winner, brings people together.
|
||||
![Dandelion held out over water][1]
|
||||
|
||||
"Growing up, I was a bit of a field marshal," Megan Byrd-Sanicki, 2020 [Women in Open Source Community Award][2] winner, says with a smile. "I was always the one pulling classmates together. 'We're going to play a game. Come on, everyone, I'll teach you the rules.' I'd also have an eye to the sidelines, trying to identify who wasn't being included and how I could draw them in."
|
||||
|
||||
![Photo by Megan Sanicki, Used with permission][3]
|
||||
|
||||
That drive to bring people together and set up a structure for them to excel carries through much of her career and community work. "I look back on who I was in second-grade gym class and have to admit that it's still who I am today."
|
||||
|
||||
Megan has been active in open source for a decade, first as Executive Director of the [Drupal Association][4], and now as the Manager of Research and Operations for Google's Open Source Program Office. "I'm fortunate in my current position because it offers a view into Google's more than 2000 open source projects with different objectives, different governance structures, and different strategies. It's been just a phenomenal learning opportunity." Megan was also recently elected to the [Open Source Initiative][5] Board of Directors, where she strives to strengthen the leadership in open source that the organization offers to projects and businesses around the globe.
|
||||
|
||||
### Lessons from the basement steps
|
||||
|
||||
Far from being set on technology, Megan originally thought she'd go into business. Sitting on the basement steps, listening to her father make sales calls, she knew his entire product line by age 16, but she also internalized other lessons.
|
||||
|
||||
"I learned from him that doing business means solving problems and helping people," Megan says. "And I've kept that front-of-mind throughout my career. In some ways, I'm not surprised by this path; it's a natural extension of who I am, but it's also taken me places I would never have dreamed possible."
|
||||
|
||||
Open source isn't just a career for Megan; she also uses the same strategies in her community involvement. "Right now, I'm working with a great group of engineers, data scientists, and epidemiologists at [Covid Act Now][6]. The team members are volunteering their expertise, collaborating openly to provide data modeling to public officials so that they can make informed decisions as quickly as possible."
|
||||
|
||||
She's also active in [FOSS Responders][7], a group focused on shining a light on open source projects and community members affected by COVID-19-related event cancellations. "In times of turmoil, it can be difficult for projects to find the help they need. We help organizations and individuals who need assistance aggregate and amplify their requests." An important component of the organization is administering the [FOSS Responders Fund][7], a mechanism to capture some of the open source funding requests that may fall through the cracks otherwise.
|
||||
|
||||
### Engaging people in a changing world
|
||||
|
||||
The twin themes that influence Megan's community engagement are a clear commitment to the principles of open source and a drive to bring people together. "When people have dreams, things they're actively trying to accomplish, it creates a shared sense of purpose and a strong 'why.' People engage easily around why. I know I do," Megan says when asked what drives her in these efforts.
|
||||
|
||||
"Whether helping raise funds for Drupal's mission or enabling open source projects to become more sustainable, there's a real human impact. I get really passionate about the butterfly effect that results from helping people meet their goals and realize their dreams and visions."
|
||||
|
||||
As open source becomes a larger and larger part of the technology space, Megan is hopeful for the future. "The exciting thing is that the story isn't done. As a community, we're still figuring things out," she says. "There's so much we need to learn about open source, and it can evolve in so many ways, while the landscape changes around us. We need to have the right conversations and figure out how to evolve together, ensuring there's a place at the table for everyone."
|
||||
|
||||
In her words, it's possible to hear those same lessons learned from listening to her father's business calls—doing business is about solving problems and helping people. "Helping more people understand how to use and contribute to open source to solve problems is really rewarding. Whether it is to drive innovation, accelerate velocity, or achieve business goals, there are lots of ways to gain value from open source."
|
||||
|
||||
### Own your awesome
|
||||
|
||||
When asked what advice she has for other women wanting to engage with the open source community, Megan lights up. "Remember that open source has room for everyone. It can be daunting, but in my experience, people want to help. Ask for help when you need it, but also be clear on where you can contribute, how you can contribute, and what your needs are."
|
||||
|
||||
She also recognizes that among all the voices in open source, a lack of centralized leadership can sometimes be felt, but she cautions against looking at it as a privileged role, reserved for only a few. "Be the leader you need. When there's a void in leadership, each individual can fill that void for themselves. Every contributor to open source is a leader, whether they're leading others, leading the community, or just leading themselves. Don't wait to be given permission and own your awesome."
|
||||
|
||||
The open source journey for Megan has been just that: a trek where her path wasn't always clear. She's never shied away from adventure or run from uncertainty, though. "I look at life as this beautiful tapestry that you're weaving, but day to day, you only get to see the threads in the back. If you could see the full picture, you'd realize that you've contributed to this wonderful work in countless ways just by doing your best every day."
|
||||
|
||||
_Also read Jay Barber's [interview with Netha Hussain][8], who won the 2020 Women in Open Source Academic Award._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/4/interview-Megan-Byrd-Sanicki
|
||||
|
||||
作者:[Jay Barber][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/jaybarber
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/dandelion_blue_water_hand.jpg?itok=QggW8Wnw (Dandelion held out over water)
|
||||
[2]: https://www.redhat.com/en/about/women-in-open-source
|
||||
[3]: https://opensource.com/sites/default/files/uploads/megan_sanicki_headshot_small_0.png (Photo by Megan Sanicki, Used with permission)
|
||||
[4]: https://www.drupal.org/association
|
||||
[5]: https://opensource.org/
|
||||
[6]: https://www.covidactnow.org/
|
||||
[7]: https://fossresponders.com/
|
||||
[8]: https://opensource.com/article/20/4/interview-Netha-Hussain
|
@ -1,142 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (nophDog)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Read and write data from anywhere with redirection in the Linux terminal)
|
||||
[#]: via: (https://opensource.com/article/20/6/redirection-bash)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
Read and write data from anywhere with redirection in the Linux terminal
|
||||
======
|
||||
Redirection is an efficient way to get data from one place to another
|
||||
without a lot of mouse moving and key pressing.
|
||||
![Hands programming][1]
|
||||
|
||||
Redirection of input and output is a natural function of any programming or scripting language. Technically, it happens inherently whenever you interact with a computer. Input gets read from `stdin` (standard input, usually your keyboard or mouse), output goes to `stdout` (standard output, a text or data stream), and errors get sent to `stderr`. Understanding that these data streams exist enables you to control where information goes when you're using a shell, such as [Bash][2] or [Zsh][3].
|
||||
|
||||
Standard in, standard out, and standard error exist as filesystem locations on Linux. You can see them in `/dev`:
|
||||
|
||||
|
||||
```
|
||||
$ ls /dev/std*
|
||||
/dev/stderr@ /dev/stdin@ /dev/stdout@
|
||||
```
|
||||
|
||||
You can't do much with them directly, but it's sometimes useful to think of them as meta-locations where you can send data.
|
||||
|
||||
The basics of redirection are simple: use some number of `>` characters to redirect output, and some number of `<` characters to redirect input.
|
||||
|
||||
### Redirecting output
|
||||
|
||||
To write the output of the [ls][4] command to a file:
|
||||
|
||||
|
||||
```
|
||||
`$ ls > list.txt`
|
||||
```
|
||||
|
||||
You don't see the output of `ls` as you normally would, because the output is written to the `list.txt` file instead of your screen. This is so versatile, in fact, that you can even use it to copy the contents of one file to another. It doesn't have to be a text file, either. You can use redirection for binary data:
|
||||
|
||||
|
||||
```
|
||||
`$ cat image.png > picture.png`
|
||||
```
|
||||
|
||||
(In case you're wondering why you'd ever want to do that, it's for a sometimes-useful repercussion on [file permissions][5].)
|
||||
|
||||
### Redirecting input
|
||||
|
||||
You can redirect input "into" a command, too. This is arguably less useful than redirecting output because many commands are already hard-coded to take input from an argument you provide. It can be useful, however, when a command expects a list of arguments, and you have those arguments in a file and want to quickly "copy and paste" them from the file into your terminal (except you don't actually want to copy and paste):
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install $(<package.list)`
|
||||
```
|
||||
|
||||
Common uses of input redirection are the **here-document** (or just **here-doc** for short) and **here-string** techniques. This input method redirects a block of text into the standard input stream, up to a special end-of-file marker (most people use `EOF`, but it can be any string you expect to be unique). Try typing this (up to the second instance of `EOF`) into a terminal:
|
||||
|
||||
|
||||
```
|
||||
$ echo << EOF
|
||||
> foo
|
||||
> bar
|
||||
> baz
|
||||
> EOF
|
||||
```
|
||||
|
||||
The expected result:
|
||||
|
||||
|
||||
```
|
||||
foo
|
||||
bar
|
||||
baz
|
||||
```
|
||||
|
||||
A **here-doc** is a common trick used by [Bash][2] scripters to dump several lines of text into a file or onto the screen. As long as you don't forget to end the clause with your end-of-file marker, it's an effective way to avoid unwieldy lists of `echo` or `printf` statements.
|
||||
|
||||
A **here-string** is similar to a **here-doc**, but it consists of just one string (or several strings disguised as a single string with quotation marks):
|
||||
|
||||
|
||||
```
|
||||
$ cat <<< "foo bar baz"
|
||||
foo bar baz
|
||||
```
|
||||
|
||||
### Redirecting error messages
|
||||
|
||||
Error messages go to a stream called `stderr`, designated as `2>` for the purposes of redirection. This command directs error messages to a file called `output.log`:
|
||||
|
||||
|
||||
```
|
||||
`$ ls /nope 2> output.log`
|
||||
```
|
||||
|
||||
### Sending data to /dev/null
|
||||
|
||||
Just as there are locations for standard in, standard out, and error, there's also a location for _nowhere_ on the Linux filesystem. It's called `null`, and it's located in `/dev`, so it's often pronounced "devnull" by people who use it too frequently to say "slash dev slash null."
|
||||
|
||||
You can send data to `/dev/null` using redirection. For instance, the `find` command tends to be verbose, and it often reports permission conflicts while searching through your files:
|
||||
|
||||
|
||||
```
|
||||
$ find ~ -type f
|
||||
/home/seth/actual.file
|
||||
find: `/home/seth/foggy': Permission denied
|
||||
find: `/home/seth/groggy': Permission denied
|
||||
find: `/home/seth/soggy': Permission denied
|
||||
/home/seth/zzz.file
|
||||
```
|
||||
|
||||
The `find` command processes that as an error, so you can redirect just the error messages to `/dev/null`:
|
||||
|
||||
|
||||
```
|
||||
$ find ~ -type f 2> /dev/null
|
||||
/home/seth/actual.file
|
||||
/home/seth/zzz.file
|
||||
```
|
||||
|
||||
### Using redirection
|
||||
|
||||
Redirection is an efficient way to get data from one place to another in Bash. You may not use redirection all the time, but learning to use it when you need it can save you a lot of needless opening files and copying and pasting data, all of which generally require mouse movement and lots of key presses. Don't resort to such extremes. Live the good life and use redirection.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/6/redirection-bash
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming)
|
||||
[2]: https://opensource.com/resources/what-bash
|
||||
[3]: https://opensource.com/article/19/9/getting-started-zsh
|
||||
[4]: https://opensource.com/article/19/7/master-ls-command
|
||||
[5]: https://opensource.com/article/19/8/linux-permissions-101
|
@ -1,205 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Yufei-Yan)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to install Java on a Mac)
|
||||
[#]: via: (https://opensource.com/article/20/7/install-java-mac)
|
||||
[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh)
|
||||
|
||||
How to install Java on a Mac
|
||||
======
|
||||
macOS users can run the open source release of Java as well as newer
|
||||
frameworks for cloud-native development.
|
||||
![Coffee and laptop][1]
|
||||
|
||||
In late May, [Java][2] celebrated its 25th anniversary, and to commemorate the occasion, developers around the world used the hashtag [#MovedByJava][3] to share their achievements, memories, and insights with the programming language.
|
||||
|
||||
> My timeline:
|
||||
>
|
||||
> * 1999 Started learning Java
|
||||
> * 2007 Created [@grailsframework][4]
|
||||
> * 2008 Cofounded G2One
|
||||
> * 2009 Acquired by SpringSource
|
||||
> * 2015 Joined [@ObjectComputing][5]
|
||||
> * 2018 Created [@micronautfw][6] / won [@groundbreakers][7] award
|
||||
> * 2019 Became [@Java_Champions][8]
|
||||
>
|
||||
> Thank u [@java][9]![#MovedByJava][10]
|
||||
>
|
||||
> — Graeme Rocher (@graemerocher) [May 21, 2020][11]
|
||||
|
||||
Over the years, many technologies and trends have contributed to the Java stack's development, deployment, and ability to run multiple applications on standard application servers. Building container images for [Kubernetes][12] enables Java developers to package and deploy [microservices][13] in multiple cloud environments rather than running several application servers on virtual machines.
|
||||
|
||||
![Timeline of technology contributions to Java][14]
|
||||
|
||||
(Daniel Oh, [CC BY-SA 4.0][15])
|
||||
|
||||
With these technologies, the Java application stack has been optimized to run larger heaps and highly dynamic frameworks that can make decisions at runtime. Unfortunately, those efforts weren't good enough to make Java the preferred programming language for developers to implement cloud-native Java applications for serverless and event-driven platforms. Other languages filled in the space, particularly JavaScript, Python, and Go, with Rust and WebAssembly offering new alternatives.
|
||||
|
||||
Despite this competition, [cloud-native Java][16] is making an impact on cloud-centric software development. Luckily, new Java frameworks (e.g., [Quarkus][17], [Micronaut][18], and [Helidon][19]) have recently broken through the challenges by offering smaller applications that compile faster and are designed with distributed systems in mind.
|
||||
|
||||
### How to install Java on macOS
|
||||
|
||||
This future for Java development starts with more people installing and using Java. So I will walk through installing and getting started with the Java development environment on macOS. (If you are running Linux, please see Seth Kenlon's article [_How to install Java on Linux_][20].)
|
||||
|
||||
#### Install OpenJDK from a Brew repository
|
||||
|
||||
Homebrew is the de-facto standard package manager for macOS. If you haven't installed it yet, Matthew Broberg's [_Introduction to Homebrew_][21] walks you through the steps.
|
||||
|
||||
Once you have Homebrew on your Mac, use the `brew` command to install [OpenJDK][22], which is the open source way to write Java applications:
|
||||
|
||||
|
||||
```
|
||||
`$ brew cask install java`
|
||||
```
|
||||
|
||||
In just a few minutes, you will see:
|
||||
|
||||
|
||||
```
|
||||
`🍺 java was successfully installed!`
|
||||
```
|
||||
|
||||
Confirm that OpenJDK installed correctly with `$ java -version`:
|
||||
|
||||
|
||||
```
|
||||
$ java -version
|
||||
openjdk version "14.0.1" 2020-04-14
|
||||
OpenJDK Runtime Environment (build 14.0.1+7)
|
||||
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing
|
||||
```
|
||||
|
||||
The output confirms OpenJDK 14 (the latest version, as of this writing) is installed.
|
||||
|
||||
#### Install OpenJDK from a binary
|
||||
|
||||
If you are not a fan of package management and prefer managing Java yourself, there's always the option to download and install it manually.
|
||||
|
||||
I found a download link to the latest version on the OpenJDK homepage. Download the OpenJDK 14 binary:
|
||||
|
||||
|
||||
```
|
||||
`$ wget https://download.java.net/java/GA/jdk14.0.1/664493ef4a6946b186ff29eb326336a2/7/GPL/openjdk-14.0.1_osx-x64_bin.tar.gz`
|
||||
```
|
||||
|
||||
Move to the directory where you downloaded the binary file and extract it:
|
||||
|
||||
|
||||
```
|
||||
`$ tar -xf openjdk-14.0.1_osx-x64_bin.tar.gz`
|
||||
```
|
||||
|
||||
Next, add Java to your PATH:
|
||||
|
||||
|
||||
```
|
||||
`$ export PATH=$PWD/jdk-14.0.1.jdk/Contents/Home/bin:$PATH`
|
||||
```
|
||||
|
||||
Also, add this to the path to your dotfiles, `.bash_profile` or `.zshrc` depending on what shell you are running. You can learn more about configuring the `$PATH` variable in [_How to set your $PATH variable in Linux_][23].
|
||||
|
||||
Finally, verify your OpenJDK 14 installation:
|
||||
|
||||
|
||||
```
|
||||
$ java -version
|
||||
openjdk version "14.0.1" 2020-04-14
|
||||
OpenJDK Runtime Environment (build 14.0.1+7)
|
||||
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
|
||||
```
|
||||
|
||||
### Write your first Java microservice on a Mac
|
||||
|
||||
Now you are ready to develop a cloud-native Java application with OpenJDK stack on macOS. In this how-to, you'll create a new Java project on [Quarkus][17] that exposes a REST API using dependency injection.
|
||||
|
||||
You will need [Maven][24], a popular Java dependency manager, to start. [Install][25] it from Maven's website or using Homebrew with `brew install maven`.
|
||||
|
||||
Execute the following Maven commands to configure a Quarkus project and create a simple web app:
|
||||
|
||||
|
||||
```
|
||||
$ mvn io.quarkus:quarkus-maven-plugin:1.5.1.Final:create \
|
||||
-DprojectGroupId=com.example \
|
||||
-DprojectArtifactId=getting-started \
|
||||
-DclassName="com.example.GreetingResource" \
|
||||
-Dpath="/hello"
|
||||
cd getting-started
|
||||
```
|
||||
|
||||
Run the application:
|
||||
|
||||
|
||||
```
|
||||
`$ ./mvnw quarkus:dev`
|
||||
```
|
||||
|
||||
You will see this output when the application starts:
|
||||
|
||||
|
||||
```
|
||||
__ ____ __ _____ ___ __ ____ ______
|
||||
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
|
||||
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
|
||||
\--\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/
|
||||
2020-06-13 00:03:06,413 INFO [io.quarkus] (Quarkus Main Thread) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 1.5.1.Final) started in 1.125s. Listening on: <http://0.0.0.0:8080>
|
||||
2020-06-13 00:03:06,416 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
|
||||
2020-06-13 00:03:06,416 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy]
|
||||
```
|
||||
|
||||
Access the REST endpoint using the `curl` command:
|
||||
|
||||
|
||||
```
|
||||
$ curl -w "\n" <http://localhost:8080/hello>
|
||||
hello
|
||||
```
|
||||
|
||||
Congratulations! You have quickly gone from not even having Java installed to building your first web application using Maven and Quarkus.
|
||||
|
||||
### What to do next with Java
|
||||
|
||||
Java is a mature programming language that continues to grow in popularity through new frameworks designed for cloud-native application development.
|
||||
|
||||
If you are on the path toward building that future, you may be interested in more practical Quarkus development lessons or other modern frameworks. No matter what you're building, the next step is configuring your text editor. Read my tutorial on [_Writing Java with Quarkus in VS Code_][26], then explore what else you can do.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/7/install-java-mac
|
||||
|
||||
作者:[Daniel Oh][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/daniel-oh
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop)
|
||||
[2]: https://opensource.com/resources/java
|
||||
[3]: https://twitter.com/search?q=%23MovedByJava&src=typed_query
|
||||
[4]: https://twitter.com/grailsframework?ref_src=twsrc%5Etfw
|
||||
[5]: https://twitter.com/ObjectComputing?ref_src=twsrc%5Etfw
|
||||
[6]: https://twitter.com/micronautfw?ref_src=twsrc%5Etfw
|
||||
[7]: https://twitter.com/groundbreakers?ref_src=twsrc%5Etfw
|
||||
[8]: https://twitter.com/Java_Champions?ref_src=twsrc%5Etfw
|
||||
[9]: https://twitter.com/java?ref_src=twsrc%5Etfw
|
||||
[10]: https://twitter.com/hashtag/MovedByJava?src=hash&ref_src=twsrc%5Etfw
|
||||
[11]: https://twitter.com/graemerocher/status/1263484918157410304?ref_src=twsrc%5Etfw
|
||||
[12]: https://opensource.com/resources/what-is-kubernetes
|
||||
[13]: https://opensource.com/resources/what-are-microservices
|
||||
[14]: https://opensource.com/sites/default/files/uploads/javatimeline.png (Timeline of technology contributions to Java)
|
||||
[15]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[16]: https://opensource.com/article/20/1/cloud-native-java
|
||||
[17]: https://quarkus.io/
|
||||
[18]: https://micronaut.io/
|
||||
[19]: https://helidon.io/#/
|
||||
[20]: https://opensource.com/article/19/11/install-java-linux
|
||||
[21]: https://opensource.com/article/20/6/homebrew-mac
|
||||
[22]: https://openjdk.java.net/
|
||||
[23]: https://opensource.com/article/17/6/set-path-linux
|
||||
[24]: https://maven.apache.org/index.html
|
||||
[25]: https://maven.apache.org/install.html
|
||||
[26]: https://opensource.com/article/20/4/java-quarkus-vs-code
|
@ -0,0 +1,74 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( guevaraya)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Open source has room for everyone)
|
||||
[#]: via: (https://opensource.com/article/20/4/interview-Megan-Byrd-Sanicki)
|
||||
[#]: author: (Jay Barber https://opensource.com/users/jaybarber)
|
||||
|
||||
开源代码广阔天地造福人类
|
||||
======
|
||||
向 2020 开源社区最佳女性获得者 Megan Byrd-Sanicki 学习是如何让大家团结起来
|
||||
|
||||
![蒲公英般浮于水面][1]
|
||||
|
||||
“再成长的过程中,我曾经是一个小小的战地执法官,” Megan Byrd-Sanicki 2020 年[开源社区最佳女性获得者][2],笑着说。“我以前经常把同学们聚在一起玩游戏。大家来吧,我们告诉你们规则。我也会注意旁听,尝试去识别未被包含的人们并把他们拉进圈子。”
|
||||
|
||||
![Megan Sanicki 的照片, 已经许可使用][3]
|
||||
|
||||
这个想法驱使我把大家都拉到一起并建立一个有吸引力的组织并贯穿职业生涯和社区工作。“我回顾曾经二年级体育课的我,必须要承认我还是曾经的我”。
|
||||
|
||||
Megan 作为第一任 [Drupal 协会][4]执行主任,十年来活跃于开源社区,现在是谷歌开源项目办公室的研发和运营主管。“我很幸运在这个职位上为谷歌的 2000 多个不同的项目目标,不同的组织架构,不同的战略的开源项目提供服务。这个也是难得的学习机会。” Megan 最近被推选为 [开源代码促进会][5]的理事会成员,她竭力领导开源社区在全球范围内的项目和企业之间的加强协作。
|
||||
|
||||
### 地下室台阶上学到的知识
|
||||
|
||||
Megan 原以为她会从商,远离循规的技术。坐在地下室台阶上,耳濡目染父亲的销售电话,到16岁时候就知道父亲的所有产品系列,也熟悉了其他知识。
|
||||
|
||||
“我从父亲学到了做生意就是解决问题和帮助别人” Megan 说。“在我的职业生涯这个信念我始终放在第一位。在某些角度看选择这条路我并不觉得奇怪;这是我个人选择的自然延伸,并且这带给我去做梦都想不到的体验”
|
||||
|
||||
开源事业对 Megan 不仅仅是一个职业;她在她的社区活动中也使用同样的理念。“现在,我与一大群优秀的工程师,数据科学家以及流行病科学家工作在[冠状病毒在行动][6]。团队成员是义务提供他们的专业知识,开发合作的为政府公共人员提供数据建模,以便他们快速的做出有效的决策。”
|
||||
|
||||
她也活跃于 [FOSS 急救会][7],这是一个为受 COVID-19事件影响的开源项目和社区成员点亮温暖的组织。“在疫情期间,很难为项目提供所需的帮忙。我们可以帮忙其他需要帮忙的组织和个人扩散他们的请求。”这个组织的一个重要的事务是管理 [FOSS 急救基金][7], 其中一个功能是寻求一个开源项目基金的融资需求,否则社区会分裂。
|
||||
|
||||
### 在这不断变化的世界中一群可爱的人
|
||||
|
||||
影响 Megan 参与到社区的两个宗旨分别是对源码代码开放的明确承诺和把大家团结在一起的动力。“人们有梦想的时候,他们就积极的去实现它,这就造就了共同的信念和强烈的 ‘为什么’。人们由于为什么很容易的聚在了一起。我知道这就是我,” Megan 在被问到她这么努力的动力时说到。
|
||||
|
||||
“不管是帮助联盟基金会筹集资金的任务还是赋能开源项目可持续发展,这些影响着这人们。我也实实在在感受到帮助人们达到他们的目标,实现他们的梦想和愿景而自己收获这种蝴蝶效应般的热情。”
|
||||
|
||||
开源技术在技术领域占的比重越来越大,Megan 对未来抱有很大希望。“令人兴奋的是故事还没有结束。作为一个社区,我们仍然在努力解决问题,”她说:“还有很多东西关于开源技术需要我们学习,我们的外部环境不断发生变化,开源将用不同的方式进化着。我们需要正确的对话和找出如何共同进化。确保每个人都有一席之地。”
|
||||
|
||||
用她的话说,经常听到这些都是从她的父亲生意电话里来的感悟,做生意就是解决问题并帮助别人。“帮助更多的人学习如何使用和贡献开源代码来解决问题的确是一件有益的事情。不管是推动创新,提供效率加快进度,还是实现业务目标,这些都是从开源代码中获取价值。”
|
||||
|
||||
### 属于你的荣耀
|
||||
|
||||
当被问到给其他想参与到开源社区的女性有哪些建议时,Megan 兴奋的说:“请记住在开源社区,所有人都有一席之地。但是从我的经验来看,这令想要获取帮助的人感到钦佩,你可以去社区求助你想要的同时,但也需要可以为社区提供力所能及的贡献,你的贡献就是其他人所求助的。”
|
||||
|
||||
他也在开源社区听到部分声音,社区有时缺乏集中领导,她警告说不要将社区领导者视为一种特权角色去服务于少数人。“做你期望的领导者。当社区领导角色空缺时,每个个体可以自己填补空缺。开与社区的每个贡献者都是领导者,不管是领导他人,领导社区,甚至领导自己。不要等待被动赋予属于你的权力和精彩。”
|
||||
|
||||
对梅金来说开源之旅就如:一个前途不明朗的心路之旅。尽管如此,对风险和未来的不确定性她从不逃避。“我把生命看作一张你正在穿着的美丽挂毯,日复一日,你仅仅看到它的线条。如果你可以看到这个全景图,你将意识到每天你正竭尽全力用各种方法为这项伟大的工作做出贡献。”
|
||||
|
||||
_可查阅 Jay Barber 的[采访 Netha Hussain][8],她是2020年度开源学术获得者._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/4/interview-Megan-Byrd-Sanicki
|
||||
|
||||
作者:[Jay Barber][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/guevaraya)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/jaybarber
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/dandelion_blue_water_hand.jpg?itok=QggW8Wnw (Dandelion held out over water)
|
||||
[2]: https://www.redhat.com/en/about/women-in-open-source
|
||||
[3]: https://opensource.com/sites/default/files/uploads/megan_sanicki_headshot_small_0.png (Photo by Megan Sanicki, Used with permission)
|
||||
[4]: https://www.drupal.org/association
|
||||
[5]: https://opensource.org/
|
||||
[6]: https://www.covidactnow.org/
|
||||
[7]: https://fossresponders.com/
|
||||
[8]: https://opensource.com/article/20/4/interview-Netha-Hussain
|
@ -0,0 +1,139 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (nophDog)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Read and write data from anywhere with redirection in the Linux terminal)
|
||||
[#]: via: (https://opensource.com/article/20/6/redirection-bash)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
通过重定向在 Linux 终端任意读写
|
||||
======
|
||||
重定向是一种十分高效的数据流动方式,它能帮你减少很多鼠标和键盘上的操作。
|
||||
![Hands programming][1]
|
||||
|
||||
对于任何编程或脚本语言,输入与输出重定向都是很自然的功能。严格来说,当你使用电脑时,数据自然而然地在发生着重定向。从 `stdin`(标准输入,通常是你的键盘或者鼠标)读取输入,输入则发往 `stdout`(标准输出,一段文本或者数据流),最后错误信息送至 `stderr`。如果你使用 [Bash][2] 或 [Zsh][3] 之类的 shell,那么理解这些数据流能够让你更好地控制信息流向。
|
||||
|
||||
标准输入,标准输出以及标准错误输出存在于 Linux 文件系统中。你可以在 `/dev` 查看:
|
||||
|
||||
|
||||
```
|
||||
$ ls /dev/std*
|
||||
/dev/stderr@ /dev/stdin@ /dev/stdout@
|
||||
```
|
||||
|
||||
你可能没法直接使用它们,但将它们想象成你能传递数据的元位置,会很有帮助。
|
||||
|
||||
重定向的基础很简单:用一些 `>` 符号重定向输出,然后用另外一些 `<` 符号重定向输入。
|
||||
|
||||
### 重定向输出
|
||||
|
||||
将 [ls][4] 命令的输出写入一个文件:
|
||||
|
||||
|
||||
```
|
||||
`$ ls > list.txt`
|
||||
```
|
||||
|
||||
你没法像平常那样看到 `ls` 的输出,因为它们并没有被发送到屏幕,而是被写入 `list.txt` 文件了,这个功能用处太多了,事实上,你甚至可以用它来将文件内容拷贝到另一个文件。不一定是文本文件,你也可以用将重定向用于二进制数据:
|
||||
|
||||
|
||||
```
|
||||
`$ cat image.png > picture.png`
|
||||
```
|
||||
|
||||
你可能会好奇为什么要这样做,有时候用来获取 [文件权限信息][5] 比较实用。
|
||||
|
||||
### 重定向输入
|
||||
|
||||
你也能将输入重定向“到”一个命令。可以说,它没有重定向输出那么有用,因为许多命令已经被硬编码,只从你的参数中接收输入。但是,如果某个命令需要一系列参数,而且你把这些参数写在文件里,想要快速“复制粘贴”到终端的时候(除非你并不想复制粘贴),它就帮得上忙了。
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install $(<package.list)`
|
||||
```
|
||||
|
||||
重定向输入得常规用法是 **here-document** (简写成 **here-doc**) 和 **here-string** 技巧。这种输入方法将一整块文本重定向至标准输入流,直到碰见一个特殊的 end-of-file 标记(许多人习惯用 `EOF`,实际上你可以使用任何字符串,只要它是唯一的)。试着把这些(在第二个 `EOF` 标记之前)敲进你的终端:
|
||||
|
||||
|
||||
```
|
||||
$ echo << EOF
|
||||
> foo
|
||||
> bar
|
||||
> baz
|
||||
> EOF
|
||||
```
|
||||
|
||||
输出结果:
|
||||
|
||||
```
|
||||
foo
|
||||
bar
|
||||
baz
|
||||
```
|
||||
|
||||
使用 [Bash][2] 编写脚本的人常常用这个技巧,将数行文本一次性写入文件或者打印到屏幕上。只要你别忘了末尾的 end-of-file 标记,这会是一个帮你避免大量繁琐 `echo` 或 `printf` 语句的好办法。
|
||||
|
||||
一句 **here-string** 类似于一段 **here-doc**,但是它只含有一个字符串(或者用引号包裹的几个字符串,同样会被当成一个字符串)
|
||||
|
||||
|
||||
```
|
||||
$ cat <<< "foo bar baz"
|
||||
foo bar baz
|
||||
```
|
||||
|
||||
### 重定向错误信息
|
||||
|
||||
错误信息流叫做 `stderr`,通过 `2>` 实现这个目的。下面这个命令把错误信息定向到 `output.log` 文件:
|
||||
|
||||
```
|
||||
`$ ls /nope 2> output.log`
|
||||
```
|
||||
|
||||
### 将数据送往 /dev/null
|
||||
|
||||
既然标准输入、标准输出和错误输出都有自己的位置,那么 _nowhere_ 也应该在 Linux 文件系统占有一席之地。没错,它叫做 `null`,位于 `/dev`,频繁使用的人懒得说 `slash dev slash null`,于是索性叫它 "devnull"。
|
||||
|
||||
通过重定向,你可以把数据发送到 `/dev/null`。比如,`find` 命令常常会输出很多具体信息,而且在搜索文件遇到权限冲突时,会事无巨细地报告:
|
||||
|
||||
|
||||
```
|
||||
$ find ~ -type f
|
||||
/home/seth/actual.file
|
||||
find: `/home/seth/foggy': Permission denied
|
||||
find: `/home/seth/groggy': Permission denied
|
||||
find: `/home/seth/soggy': Permission denied
|
||||
/home/seth/zzz.file
|
||||
```
|
||||
|
||||
`find` 命令把那些当作错误,所以你可以只把错误信息重定向至 `/dev/null`:
|
||||
|
||||
|
||||
```
|
||||
$ find ~ -type f 2> /dev/null
|
||||
/home/seth/actual.file
|
||||
/home/seth/zzz.file
|
||||
```
|
||||
|
||||
### 使用重定向
|
||||
|
||||
在 Bash 中,重定向是转移数据的有效方法。你可能不会频繁使用重定向,但是学会如何使用它,能帮你在打开文件、复制粘贴数据这类需要移动鼠标、大量按键操作上,节省很多不必要的时间。不要做如此浪费时间的事情。使用重定向,好好享受生活。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/6/redirection-bash
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/nophDog)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming)
|
||||
[2]: https://opensource.com/resources/what-bash
|
||||
[3]: https://opensource.com/article/19/9/getting-started-zsh
|
||||
[4]: https://opensource.com/article/19/7/master-ls-command
|
||||
[5]: https://opensource.com/article/19/8/linux-permissions-101
|
198
translated/tech/20200701 How to install Java on a Mac.md
Normal file
198
translated/tech/20200701 How to install Java on a Mac.md
Normal file
@ -0,0 +1,198 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Yufei-Yan)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to install Java on a Mac)
|
||||
[#]: via: (https://opensource.com/article/20/7/install-java-mac)
|
||||
[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh)
|
||||
|
||||
如何在 Mac 上安装 Java
|
||||
======
|
||||
|
||||
macOS 用户可以运行 Java 的开源版本,同时也可以运行用于<ruby>云原生<rt>cloud native</rt></ruby>开发的新框架。
|
||||
|
||||
![Coffee and laptop][1]
|
||||
|
||||
五月底,Java 庆祝了它的 25 周年纪念日,为了纪念这一时刻,世界各地的开发人员使用 [#MovedByJava][3] 这一标签分享他们使用这一编程语言的成就,记忆以及愿景。
|
||||
|
||||
> 我的时间线:
|
||||
>
|
||||
> * 1999 开始学习 Java
|
||||
> * 2007 创建 [@grailsframework][4]
|
||||
> * 2008 共同创建 G20ne
|
||||
> * 2009 被 SpringSource 收购
|
||||
> * 2015 加入 [@ObjectComputing][5]
|
||||
> * 2018 创建 [@micronautfw][6] / 获得 [@groundbreakers][7] 奖
|
||||
> * 2019 成为 [@Java_Champions][8]
|
||||
>
|
||||
> 感谢你 [@java][9]![#MovedByJava][10]
|
||||
>
|
||||
> — Graeme Rocher (@graemerocher) [2020年5月21日][11]
|
||||
|
||||
多年来,许多技术和趋势都促进了 Java 堆栈的开发,部署和在标准应用程序服务器上运行多个应用的能力。为 [Kubernetes][12] 构建容器镜像使得 Java 开发者可以在多个云环境中打包和部署<ruby>[微服务][13]<rt>microservices</rt></ruby>,而不是在虚拟机上运行几个应用程序服务器。
|
||||
|
||||
![Timeline of technology contributions to Java][14]
|
||||
|
||||
(Daniel Oh, [CC BY-SA 4.0][15])
|
||||
|
||||
有了这些技术,Java 应用程序栈被优化为运行更大的堆和可以在运行时做出决策的高动态框架。然而不幸的是,这些努力还不足以使 Java 成为开发人员为无服务和事件驱动平台开发<ruby>云原生<rt>cloud native</rt></ruby> Java 应用程序的首选编程语言。其他语言填补了这部分空缺,特别是 JavaScript,Python,和 Go,而 Rust 和 WebAssembly 也提供了新的选项。
|
||||
|
||||
尽管存在这种竞争,[<ruby>云原生<rt>cloud native</rt></ruby> Java][16] 正在对以云为中心的软件开发产生影响。幸运的是,新的 Java 框架(比如,[Quarkus][17],[Micronaut][18],和 [Helidon][19])最近已经战胜了这些挑战,他们提供了编译更快而且更小的应用,同时他们在设计之初就将分布式系统考虑了进去。
|
||||
|
||||
### 如何在 macOS 上安装 Java
|
||||
|
||||
Java 开发的未来将从更多人安装和使用 Java 开始。因此,我将介绍如何在 macOS 上安装并开始使用 Java 开发环境。(如果你运行的是 Linux,请查看 Seth Kenlon 的文章 [如何在 Linux 上安装 Java][20]。)
|
||||
|
||||
#### 通过 Brew 仓库安装 OpenJDK
|
||||
|
||||
Homebrew 实际上算是 macOS 上的标准包管理器。如果你还没有安装的话,Matthew Broberg 的文章,[_Homebrew 简介_][12],将带你完成这些步骤。
|
||||
|
||||
当你在 Mac 上安装好 Homebrew 后,使用 `brew` 命令安装 [OpenJDK][22],这是编写 Java 应用程序的开源方式:
|
||||
|
||||
```
|
||||
$ brew cask install java
|
||||
```
|
||||
|
||||
不到一分钟就能看到:
|
||||
|
||||
```
|
||||
$ java was successfully installed!
|
||||
```
|
||||
|
||||
通过 `$ java -version` 命令确认 OpenJDK 已经正确安装:
|
||||
|
||||
```
|
||||
$ java -version
|
||||
openjdk version "14.0.1" 2020-04-14
|
||||
OpenJDK Runtime Environment (build 14.0.1+7)
|
||||
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing
|
||||
```
|
||||
|
||||
从输出中可以确认 OpenJDK 14 (本文撰写时的最新版本)已经安装。
|
||||
|
||||
#### 从二进制文件安装 OpenJDK
|
||||
|
||||
|
||||
如果你并不热衷于包管理器,并且更愿意自己来管理 Java 的话,那么你总是可以选择下载并且手动安装。
|
||||
|
||||
我在 OpenJDK 主页上找到了最新版本的下载链接。下载 OpenJDK 14 的二进制文件:
|
||||
|
||||
```
|
||||
$ wget https://download.java.net/java/GA/jdk14.0.1/664493ef4a6946b186ff29eb326336a2/7/GPL/openjdk-14.0.1_osx-x64_bin.tar.gz
|
||||
```
|
||||
|
||||
移动到你保存二进制文件的目录,然后解压:
|
||||
|
||||
```
|
||||
$ tar -xf openjdk-14.0.1_osx-x64_bin.tar.gz
|
||||
```
|
||||
|
||||
接下来,将 Java 加入到你的 PATH:
|
||||
|
||||
```
|
||||
$ export PATH=$PWD/jdk-14.0.1.jdk/Contents/Home/bin:$PATH
|
||||
```
|
||||
|
||||
同时,将这条命令加到你的 dotfile 中,`.bash_profile` 还是 `.zshrc` 取决于你运行的 shell。你可以在[_如何在 Linux 中设置你的 \$PATH 变量_][23]一文中了解更多关于配置 `$PATH` 变量的内容。
|
||||
|
||||
最后,验证你安装的 OpenJDK 14:
|
||||
|
||||
```
|
||||
$ java -version
|
||||
openjdk version "14.0.1" 2020-04-14
|
||||
OpenJDK Runtime Environment (build 14.0.1+7)
|
||||
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
|
||||
```
|
||||
|
||||
### 在 Mac 上编写你的第一个<ruby>[微服务][13]<rt>microservices</rt></ruby>
|
||||
|
||||
现在,你已经准备好在 maxOS 上使用 OpenJDK 堆栈开发<ruby>云原生<rt>cloud native</rt></ruby> Java 应用程序了。在本教程中,你将在 [Quarkus][17] 上创建一个新的 Java 项目,这个项目使用<ruby>依赖注入<rt>dependency injection</rt></ruby>来暴露 REST API。
|
||||
|
||||
你需要 [Maven][24] 启动,它是一个非常流行的 Java 依赖管理器。从 Maven 的网站或者通过 Homebrew 使用 `brew install maven` 命令[安装][25]。
|
||||
|
||||
执行以下 Maven 命令来配置 Quarkus 项目,并且创建一个简单的 web 应用:
|
||||
|
||||
```
|
||||
$ mvn io.quarkus:quarkus-maven-plugin:1.5.1.Final:create \
|
||||
-DprojectGroupId=com.example \
|
||||
-DprojectArtifactId=getting-started \
|
||||
-DclassName="com.example.GreetingResource" \
|
||||
-Dpath="/hello"
|
||||
cd getting-started
|
||||
```
|
||||
|
||||
运行这个应用:
|
||||
|
||||
|
||||
```
|
||||
$ ./mvnw quarkus:dev
|
||||
```
|
||||
|
||||
当应用程序运行的时候,你可以看到这个输出:
|
||||
|
||||
|
||||
```
|
||||
__ ____ __ _____ ___ __ ____ ______
|
||||
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
|
||||
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
|
||||
\--\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/
|
||||
2020-06-13 00:03:06,413 INFO [io.quarkus] (Quarkus Main Thread) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 1.5.1.Final) started in 1.125s. Listening on: <http://0.0.0.0:8080>
|
||||
2020-06-13 00:03:06,416 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
|
||||
2020-06-13 00:03:06,416 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy]
|
||||
```
|
||||
|
||||
使用 `curl` 命令访问 REST 端点:
|
||||
|
||||
```
|
||||
$ curl -w "\n" <http://localhost:8080/hello>
|
||||
hello
|
||||
```
|
||||
|
||||
恭喜!通过使用 Mavan 和 Quarkus,你很快从没有安装 Java 的环境里创建了第一个 web 应用。
|
||||
|
||||
### 接下来用 Java 做什么
|
||||
|
||||
Java 是一个成熟的编程语言,通过专门为<ruby>云原生<rt>cloud native</rt></ruby>应用程序开发设计的新框架,Java 的热度会一直持续下去。
|
||||
|
||||
如果你正走在这样构建未来应用的路上,你可能会对更多实用的 Quarkus 开发课程或其他现代化框架感兴趣。无论你在构建什么,下一步是配置你的文本编辑器。阅读我关于[_在 VS Code 用 Quarkus 编写 Java_][26] 的教程,然后再看看你能做什么。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/7/install-java-mac
|
||||
|
||||
作者:[Daniel Oh][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[Yufei-Yan](https://github.com/Yufei-Yan)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/daniel-oh
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop)
|
||||
[2]: https://opensource.com/resources/java
|
||||
[3]: https://twitter.com/search?q=%23MovedByJava&src=typed_query
|
||||
[4]: https://twitter.com/grailsframework?ref_src=twsrc%5Etfw
|
||||
[5]: https://twitter.com/ObjectComputing?ref_src=twsrc%5Etfw
|
||||
[6]: https://twitter.com/micronautfw?ref_src=twsrc%5Etfw
|
||||
[7]: https://twitter.com/groundbreakers?ref_src=twsrc%5Etfw
|
||||
[8]: https://twitter.com/Java_Champions?ref_src=twsrc%5Etfw
|
||||
[9]: https://twitter.com/java?ref_src=twsrc%5Etfw
|
||||
[10]: https://twitter.com/hashtag/MovedByJava?src=hash&ref_src=twsrc%5Etfw
|
||||
[11]: https://twitter.com/graemerocher/status/1263484918157410304?ref_src=twsrc%5Etfw
|
||||
[12]: https://opensource.com/resources/what-is-kubernetes
|
||||
[13]: https://opensource.com/resources/what-are-microservices
|
||||
[14]: https://opensource.com/sites/default/files/uploads/javatimeline.png (Timeline of technology contributions to Java)
|
||||
[15]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[16]: https://opensource.com/article/20/1/cloud-native-java
|
||||
[17]: https://quarkus.io/
|
||||
[18]: https://micronaut.io/
|
||||
[19]: https://helidon.io/#/
|
||||
[20]: https://opensource.com/article/19/11/install-java-linux
|
||||
[21]: https://opensource.com/article/20/6/homebrew-mac
|
||||
[22]: https://openjdk.java.net/
|
||||
[23]: https://opensource.com/article/17/6/set-path-linux
|
||||
[24]: https://maven.apache.org/index.html
|
||||
[25]: https://maven.apache.org/install.html
|
||||
[26]: https://opensource.com/article/20/4/java-quarkus-vs-code
|
Loading…
Reference in New Issue
Block a user