Skip to content

Instantly share code, notes, and snippets.

@DiamondI
DiamondI / sed_text_replace.md
Created September 29, 2020 06:24
[用sed做文本替换] #sed #terminal

用sed做文本替换

sed做文本替换的语法如下:

语法

sed 's/old/new/g'

例子

@DiamondI
DiamondI / awk_syscall.md
Created September 29, 2020 06:12
[在awk中调用系统命令] #awk #terminal

在awk中调用系统命令

使用system即可。

例子

比如有一个文本文件htmlfile.txt,其中每一行都是html文件的文件名,如果想要将其中的文件都复制到目录utf8html下的话,可以像这样写:

awk '{print $1; system("cp " $1 " utf8html")}' ./htmlfile.txt
@DiamondI
DiamondI / additional.md
Last active September 24, 2020 10:48
[我眼中的Gist] #gist #introduction

我发现我错了,一个gist里似乎可以有多个文件!

@DiamondI
DiamondI / helloworld_for_commander.js
Last active September 24, 2020 10:42
[hello world for commander] #commander #terminal #introduction
console.log("hello, world!");
var program = require("commander");
program
.version('0.0.1')
.usage('[options] [value ...]')
.option("-s, --string <string>", "a string argument");
program.parse(process.argv);
console.log(program.string);