show colored word in bash

echo color in bash console

1
echo -e "\033[01;32m 绿色字体 √ \033[0m"
1
console.log('\033[01;32m', '绿色字体 √')

color matrix

1
2
3
4
5
6
7
8
9
for (let i = 0; i < 64; i++) {
for (let j = 32; j < 48; j++) {
const ii = i.toString().padStart(2, '0')
const jj = j.toString().padStart(2, '0')
const str = '\033' + `[${ii};${jj}m` + `[${ii};${jj}m` + '\033[0m '
process.stdout.write(str)
}
process.stdout.write('\n')
}

Check Chinese Word

使用grep -r读取当前文件夹下的所有文件内容,使用正则匹配筛选中文

1
2
3
const child = require('child_process')
const all = child.execSync(`grep -r ''`).toString().split('\n').map(l => l.trim()).filter(l => l.length)
const chinese = all.filter(l => /[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/.test(l))