markdown 使用ruby代替grep / awk / sed就像perl一样

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 使用ruby代替grep / awk / sed就像perl一样相关的知识,希望对你有一定的参考价值。

With options `-e`, `-n`, `-p`, perl can do what grep/awk/sed can, what about ruby?

Let's take the result of `ls -l` as input and process it with ruby

### grep with ruby
`\ls -l | ruby -ne 'print if /^d/'`

### awk with ruby
`\ls -l | ruby -ne 'puts split(/\s+/).last if /^d/'`

### sed with ruby
`\ls -l | ruby -pe 'gsub /.*\s+(\S+)$/, %q|\1|'`  
`\ls -l | ruby -pe 'gsub(/.*\s+(\S+)$/) {$1.capitalize}'`

以上是关于markdown 使用ruby代替grep / awk / sed就像perl一样的主要内容,如果未能解决你的问题,请参考以下文章

用Ruby和rb-appscript代替Applescript发送苹果邮件

markdown Grep使用

markdown 使用rbenv切换Ruby版本

更好的 ruby​​ markdown 解释器?

markdown使用语法,typora

markdown linux,命令,grep