Last updated about 1 week ago

sed (stream editor)

echo "Line 1\nLine 2" | sed "G"
# --> "\nLine 1\n\nLine 2\n"
# Say we wanna add a file.md's last modified time to it's frontmatter
modified=$(date -r file.md); sed -e "1s/^/---\nmodified: "$modified"\n---\n/g" file.md
sed "2 s/.*/modified: \"$(date -r file.md)\"/" file.md
where `2` in the command represents the second line