summary refs log tree commit diff
path: root/_posts/2019-04-24-shell.md
diff options
context:
space:
mode:
authormayx2022-03-27 15:07:44 +0000
committermayx2022-03-27 15:07:44 +0000
commitde16f53f0577f1945dc5832ad03db2ab6fb90285 (patch)
tree78211af26cc45d7b65a60a094db05f81088a4c96 /_posts/2019-04-24-shell.md
parente78ff9779d446680f1672b7e557b23a15c3cfdb0 (diff)
更新 _posts/2022-03-27-radio.md, _posts/2019-04-24-shell.md, _posts/2021-05-07-ssh.md, _posts/2022-03-12-alpine.md, _posts/2022-02-15-termux.md
Diffstat (limited to '_posts/2019-04-24-shell.md')
-rw-r--r--_posts/2019-04-24-shell.md6
1 files changed, 3 insertions, 3 deletions
diff --git a/_posts/2019-04-24-shell.md b/_posts/2019-04-24-shell.md
index 04e09c2..d42acb3 100644
--- a/_posts/2019-04-24-shell.md
+++ b/_posts/2019-04-24-shell.md
@@ -9,13 +9,13 @@ tags: [Shell, 编程]
 <!--more-->
 
 Shell 脚本很棒,你可以非常轻松地写出有用的东西来。甚至像是下面这个傻瓜式的命令:
-```
+```shell
 # 用含有 Go 的词汇起名字:
 $ grep -i ^go /usr/share/dict/* | cut -d: -f2 | sort -R | head -n1
 goldfish
 ```
 如果用其他编程语言,就需要花费更多的脑力,用多行代码实现,比如用 Ruby 的话:
-```
+```ruby
 puts(Dir['/usr/share/dict/*-english'].map do |f|
   File.open(f)
     .readlines
@@ -25,7 +25,7 @@ end.flatten.sample.chomp)
 Ruby 版本的代码虽然不是那么长,也并不复杂。但是 shell 版是如此简单,我甚至不用实际测试就可以确保它是正确的。而 Ruby 版的我就没法确定它不会出错了,必须得测试一下。而且它要长一倍,看起来也更复杂。   
 
 这就是人们使用 Shell 脚本的原因,它简单却实用。下面是另一个例子:
-```
+```shell
 curl https://nl.wikipedia.org/wiki/Lijst_van_Nederlandse_gemeenten |
     grep '^<li><a href=' |
     sed -r 's|<li><a href="/wiki/.+" title=".+">(.+)</a>.*</li>|\1|' |