Skip to content

Commit

Permalink
24/12/22
Browse files Browse the repository at this point in the history
  • Loading branch information
WindRunnerMax committed Dec 22, 2024
1 parent ae7866e commit 60aa6ad
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 2 deletions.
54 changes: 53 additions & 1 deletion .scripts/sync-blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const blog = path.resolve(root, `../Blog`);
await exec(`rm -rf ${blog}/${group}`);
await exec(`cp -r ${from} ${blog}`);
}

console.log("Processing _sidebar.md");
const body: string[] = [];
for (const [key, value] of Object.entries(docs)) {
Expand All @@ -31,4 +31,56 @@ const blog = path.resolve(root, `../Blog`);
}
const content = body.join("\n");
await fs.writeFile(path.join(blog, "_sidebar.md"), content);

console.log("Processing sitemap.xml");
const allPath: string[] = [];
Object.values(docs).forEach((value) => allPath.push(...value));
const getGitLastUpdatedTimeStamp = async (filePath: string) => {
let lastUpdated: number | null = null;
try {
const context = path.dirname(filePath);
const cmd = `cd ${context} && git log -1 --format=%at ${filePath}`;
const { stdout } = await exec(cmd);
lastUpdated = Number(stdout) * 1000;
if (Number.isNaN(lastUpdated)) lastUpdated = null;
} catch (e) {
/* noop */
}
return lastUpdated;
};
const domain = "https://blog.touchczy.top/";
const sitemap: string[] = [];
sitemap.push(`<?xml version="1.0" encoding="UTF-8"?>`);
sitemap.push(`<urlset`);
sitemap.push(` xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"`);
sitemap.push(` xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"`);
sitemap.push(
` xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9`
);
sitemap.push(` http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"`);
sitemap.push(`>\n`);

sitemap.push(`<url>`);
sitemap.push(` <loc>${domain}</loc>`);
sitemap.push(` <priority>1.0</priority>`);
sitemap.push(`</url>\n`);

sitemap.push(`<url>`);
sitemap.push(` <loc>${domain}_sidebar.md</loc>`);
sitemap.push(` <priority>1.0</priority>`);
sitemap.push(`</url>\n`);

for (const filePath of allPath) {
const file = path.join(blog, filePath + ".md");
console.log("Process File:", file);
const time = await getGitLastUpdatedTimeStamp(file);
sitemap.push(`<url>`);
sitemap.push(` <loc>${domain}${filePath}.md</loc>`);
sitemap.push(` <priority>1.0</priority>`);
time &&
sitemap.push(` <lastmod>${new Date(time).toISOString()}</lastmod>`);
sitemap.push(`</url>\n`);
}
sitemap.push(`</urlset>`);
fs.writeFile(path.join(blog, "sitemap.xml"), sitemap.join("\n"));
})();
98 changes: 98 additions & 0 deletions Backup/du命令.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# du命令
`du`命令是`Disk Usage`的缩写,用于估算和显示文件系统中的文件和目录的磁盘使用情况。

## 语法

```bash
du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F
```

## 参数
* `-a, --all`: 对所有文件计数,包括目录。
* `--apparent-size`: 打印表观大小,而不是磁盘使用量。虽然表观大小通常较小,但由于稀疏文件的孔洞、内部碎片和间接块,其可能更大。
* `-B, --block-size=SIZE`: 在打印之前按`SIZE`缩放大小。例如,`-BM``1,048,576`字节为单位打印大小。
* `-b, --bytes`: 相当于 `--apparent-size --block-size=1`
* `-c, --total`: 显示总计。
* `-D, --dereference-args`: 只解除命令行中列出的符号链接的引用。
* `--files0-from=F`: 汇总文件F中指定的以空字节终止的文件名的磁盘使用情况,如果`F``-`,则从标准输入读取名字。
* `-H`: 相当于 `--dereference-args (-D)`
* `-h, --human-readable`: 以人类可读的格式打印大小,舍入数值并使用缩写。例如,`1K``234M``2G`等。
* `--si`: 类似于 `-h`,但使用`1000`的幂,而不是`1024`
* `-k`: 类似于 `--block-size=1K`
* `-l, --count-links`: 多次计算大小(如果有硬链接)。
* `-m`: 类似于 `--block-size=1M`
* `-L, --dereference`: 引用所有符号链接。
* `-P, --no-dereference`: 不追踪任何符号链接(这是默认设置)。
* `-0, --null`: 用0字节而不是换行符结束每个输出行。
* `-S, --separate-dirs`: 不包括子目录的大小。
* `-s, --summarize`: 仅针对每个参数显示总计。
* `-x, --one-file-system`: 跳过不同文件系统上的目录。
* `-X, --exclude-from=FILE`: 排除与`FILE`中的任何模式匹配的文件。
* `--exclude=PATTERN`: 排除与`PATTERN`匹配的文件。
* `-d, --max-depth=N`: 仅在目录(或文件,带有`--all`时)位于命令行参数以下的`N`个或更少级别时才打印总计,`--max-depth=0`等同于`--summarize`
* `--time`: 显示目录中任何文件或其子目录的最后修改时间。
* `--time=WORD`: 按`WORD`而不是修改时间显示时间:`atime`, `access`, `use`, `ctime``status`
* `--time-style=STYLE`: 使用样式`STYLE`显示时间:`full-iso`, `long-iso`, `iso`,或`+`格式(`FORMAT`的解释类似于`date`的格式)。
* `--help`: 显示帮助信息并退出。
* `--version`: 输出版本信息并退出。

## 示例

显示当前目录及其子目录所占的磁盘空间。

```bash
du -h
```

仅显示某个特定目录的磁盘使用情况,默认会递归地显示目录使用情况。

```bash
du -h /home
```

递归地显示某个目录下每个文件和子目录所占的空间,并最终汇总显示总使用空间。

```bash
du -ah /home
```

显示当前目录下的一级子目录的空间使用情况。

```bash
du -h -d 1
```

显示文件系统的磁盘空间使用情况`disk free`

```bash
df -h
```

显示当前目录下的所有文件和子目录的磁盘使用情况,并按照大小排序。

```bash
du -h -d 1 | sort -h -r
```

显示当前目录下的所有文件和子目录的磁盘使用情况,排除部分文件夹,并按照大小排序。

```bash
du -h -d 1 --exclude=.git --exclude=node_modules | sort -h -r
du -h -d 1 -I .git -I node_modules | sort -h -r # Mac
```


## 每日一题

```
https://github.com/WindrunnerMax/EveryDay
```

## 参考

```
https://www.computerhope.com/unix/udu.htm
https://linuxize.com/post/du-command-in-linux/
https://www.runoob.com/linux/linux-comm-du.html
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
如果觉得还不错,点个`star`吧 😁

<!-- Summary Start -->
版本库中共有`489`篇文章,总计`92189`行,`1085701`字,`3028732`字符。
版本库中共有`491`篇文章,总计`92468`行,`1088853`字,`3035502`字符。
<!-- Summary End -->

这是一个前端小白的学习历程,如果只学习而不记录点什么那基本就等于白学了。这个版本库的名字`EveryDay`就是希望激励我能够每天学习,下面的文章就是从`2020.02.25`开始积累的文章,都是参考众多文章归纳整理学习而写的,文章包括了`HTML`基础、`CSS`基础、`JavaScript`基础与拓展、`Browser`浏览器相关、`Vue`使用与分析、`React`使用与分析、`Plugin`插件相关、`RichText`富文本、`Patterns`设计模式、`Linux`命令、`LeetCode`题解等类别,内容都是比较基础的,毕竟我也还是个小。此外基本上每个示例都是本着能够即时运行为目标的,新建一个`HTML`文件复制之后即可在浏览器运行或者直接可以在`console`中运行。
Expand Down

0 comments on commit 60aa6ad

Please sign in to comment.