如何更好的学习 shell 编程

2020-11-23 05:51:46 +08:00
 b0644170fc
shell 编程对于服务器开发我干觉很重要。但是 shell 的语法也让我很琢磨不透。有没有什么网站或者资料之类的可以让我大量的练习 shell 编程。平常自己找场景练习 shell 的机会感觉还是太少了。有了解的大佬知道有类似的网站或资料吗?
5718 次点击
所在节点    程序员
36 条回复
Livid
2020-11-23 06:05:40 +08:00
https://www.oreilly.com/library/view/bash-cookbook-2nd/9781491975329/

能够用 shell 解决的各类实际问题。
opensail
2020-11-23 06:25:26 +08:00
@Livid 感谢
Death
2020-11-23 08:05:01 +08:00
也可以看一下这个,有很多练习与例子 https://tldp.org/LDP/abs/html/
hanxiV2EX
2020-11-23 08:22:50 +08:00
学完基础语法后,多练习就好了,平时遇到想不起来的搜索一下就好了。我经常想不起来 for 循环语句如何写
zouzou0208
2020-11-23 08:54:26 +08:00
@Livid 收藏了,谢谢。
eccstartup
2020-11-23 09:04:59 +08:00
很多功能可以用 python 做了,可以考虑写 python 脚本。
Kobayashi
2020-11-23 09:06:55 +08:00
@Death 友情提示,ABSD, Advanced Bash-Scripting Guide 是 IRC #bash 公认的臭名昭著的教程。

https://www.reddit.com/r/linuxadmin/comments/8q99sk/advanced_bashscripting_guide_an_indepth/
> Here is what the bot in #bash on freenode has to say about the guide:

> The infamous "Advanced" Bash Scripting Guide should be avoided unless you know how to filter out the junk. It will teach you to write bugs, not scripts. In that light, the BashGuide was written: http://mywiki.wooledge.org/BashGuide

写 bug,学 ABSD 。
Kobayashi
2020-11-23 09:16:07 +08:00
@Kobayashi 系统学习 Bash 推荐读一下 wooledge wiki 中 BasgGuide 。这个 wiki 更大的精华在于其 FAQ 和 Pitfalls 两个板块。好像是 IRC #bash 总有人遇到这些问题而归纳出的常见错误。
no1xsyzy
2020-11-23 09:17:11 +08:00
@Kobayashi 哈哈 @谭浩强
yalin
2020-11-23 09:21:44 +08:00
在 CentOS 机器上面安装一下 Oracle
Kobayashi
2020-11-23 09:29:49 +08:00
还有个趣事儿。zinit 作者曾经炮轰 zsh 社区 antigen 管理不善,认为后者作为 zsh 官方社区插件管理器,引入了很多垃圾代码,很有 ABSG programming style

https://www.reddit.com/r/zsh/comments/536rdy/want_to_try_zsh_again_what_about_antibody/
xiaket
2020-11-23 09:34:44 +08:00
我们公司有个不成文的规则, 超过一定行数的 bash 脚本会被要求改写成 python.
Death
2020-11-23 09:45:02 +08:00
@Kobayashi
这个我还是第一次知道,感谢提醒。
itabas016
2020-11-23 09:45:34 +08:00
多写就好了。先用 bash 写自动化功能,实在复杂的再用 py
chaleaoch
2020-11-23 10:21:36 +08:00
太复杂的用 python. 简单的看看阮一峰老师的博客就足够了.

wangdoc.com
reyleon
2020-11-23 10:48:15 +08:00
@Kobayashi 很明显 Advanced Bash-Scripting Guide 是拿来当手册用的啊,我就觉得这书当手册相当好
Kobayashi
2020-11-23 15:01:14 +08:00
我说的不是 Advanced Bash-Script Guide 是属于手册还是教程的问题。我只是在 reddit 上不止一次看到人提及其为垃圾。

https://www.reddit.com/r/commandline/comments/8q99nd/advanced_bashscripting_guide_an_indepth/e0hiuh1/

https://www.reddit.com/r/bash/comments/4l8w53/cash_library_of_function_review/d3lqqt4/

尽管大部分人都是草台班子,但学的话谁都想学好,不想学的是错误的写法,不是吗?
Kobayashi
2020-11-23 15:01:29 +08:00
f6x
2020-11-23 15:05:08 +08:00
shell 不是拿来学的, 是拿来用的.

每次(查)用完, 再多 man 十分钟就行了.
beidounanxizi
2020-11-23 15:07:24 +08:00
https://book.douban.com/subject/11589828/ Linux 命令行与 shell 脚本编程大全

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/728172

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX