#!/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)" cdsource/_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