aliases | category | classification | date | date_modified | draft | id | image | links | local_archive_links | pinned | series | tags | title | type | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
sed |
public |
2020-06-01 11:03:09 -0700 |
2020-06-01 11:03:09 -0700 |
false |
20200601180309 |
false |
false |
|
sed Cheatsheet |
tech-note |
# Prepend to beginning of line number:
sed '<line>s/^/hello/' <file>
# Multiple `sed` commands:
sed '337s/^/+++<s>+++/; 337s/$/+++<\/s>+++/' <file>
# Regex to identify numbers as \d{*} doesn't work:
sed 's/?ref=v[0-9]*\.[0-9]*\.[0-9]*//g'
# Takes filename minus ending and appends to image frontmatter path.
for file in *.md; do BOOK=$(basename --suffix=.md $file) && sed --in-place=.orig "7s/$/$BOOK.png/" $file; done
# Replace ## Chapter with frontmatter book name:
for file in *.md; do BOOK=$(grep "book: " $file | sed 's/book: //'); echo $BOOK && sed --in-place=.orig "s/## Chapter/## $BOOK/" $file ; done