添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash

# Initialize the timestamp variable with the current date and time
tsf=$(mktemp)
echo $(date -u -d "2024-04-09 23:44:24" +%s) >$tsf
echo "tsf=$tsf"

# Function to prepend text to a file
prepend() {
local tempFile
tempFile=$(mktemp)
echo "$2" > "$tempFile"
cat "$1" >> "$tempFile"
mv "$tempFile" "$1"
}

# Function to generate the content to be prepended
generate_content() {
filename=$(basename "$1" .md)

# Increment the timestamp by one second
ts=$(($(cat $tsf) - 1))

# Convert the timestamp to the date format
date=$(date -u -d "@$ts" +"%Y-%m-%d %T")
echo $ts >$tsf
echo "---
title: $filename
categories:
- [jackfrued-Python-temp]
date: $date
draft: false
tags:
---
"
}

CWD="$(pwd)"

cd source/_posts/Python-100-Days
git reset --hard
rm -r res
rm -r "公开课"
rm -r "番外篇"
rm *.md
# Main script
for file in $(find . -name "*.md"|grep Day |sort); do
content=$(generate_content "$file")
prepend "$file" "$content"
done

本文采用 署名-非商业性使用-相同方式共享 4.0 国际 许可协议,转载请注明出处。