Linux 中批量替换目录下所有文件内容

替换内容

1
sed -i "s/oldString/newString/g"  `grep oldString -rl /path`

替换标题

1
rename [-v] [-n] [-f] perlexpr [filenames]

其中:

  • v 显示文件重命名的细节

  • n 不执行重命名,但会模拟执行重命名,并显示会出现的情况,例如是否会有同名文件冲突等。在重命名前测试很有用。

  • f 强制覆盖同名文件

例如:

1
rename "s/small/large/" image_*.png

Read More

Github Pages 迁移到 Gitlab Pages

本文最后更新于 2019 年 4 月 7 日


最近询问如何将 Github Pages 迁移到 Gitlab Pages 上的小伙伴还挺多的,本文介绍在使用 Hugo 或 Hexo 时,如何进行这种迁移。

静态文件

无论对于 Hexo 还是 Hugo,这个方法都是通用的,之前怎么 push 到 git server 上还是怎么 push,这部分略做 github 和 gitlab 的修改即可。在推上去的根目录下有这样一个叫做 .gitlab-ci.yml 的文件即可:

.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
image: alpine:latest

pages:
stage: deploy
script:
- mkdir .public
- cp -r * .public
- mv .public public
artifacts:
paths:
- public
only:
- master

Read More

Windows 下搭建 Hexo 博客并部署到 Github 上

本文介绍如何在 Windows 系统下搭建一个 Hexo 博客,并部署到 Github Pages 上。

准备

下载并安装 Git 客户端

https://git-scm.com/

下载并安装 Node.js 环境

https://nodejs.org/

Github 注册

注册帐号,例如用户名为 test 。新建一个仓库,命名为: test.github.io

在任意空白处右键,选择 Git Bash Here ,在命令行窗口执行如下命令:

1
2
git config --global user.name "Your name"
git config --global user.email "Your email address"

绑定密钥

在 Git Bash 中:

1
ssh-keygen -t rsa -C "username@hostname"

生成的密钥对储存在: C:\Users\username\.ssh 中。找到公钥,并添加到 Github 上。

npm 换源

1
npm config set registry http://registry.npm.taobao.org

Read More

Ubuntu 下安装配置 Haskell 环境

本文最后更新于 2019 年 3 月 25 日


本文以 Ubuntu 18.04 为例,介绍如何安装配置 Haskell 环境。


安装编译所需库

1
sudo apt update && sudo apt install build-essential libgmp3-dev zlib1g-dev libnuma-dev -y

安装 ghcp

执行如下命令:

1
curl https://raw.githubusercontent.com/haskell/ghcup/master/bootstrap-haskell -sSf | sh

设置环境变量

1
2
. "$HOME/.ghcup/env"
echo '. $HOME/.ghcup/env' >> "$HOME/.bashrc"

Read More

Mastodon