Git Warning: LF Will Be Replaced by CRLF

I’m using Git Bash while writing this post. I’ve never tested the commands on *nix.

Background

Some of the tags and titles were written as “LateX”/“latex” in the source files. I batch corrected them with Git Grep and GNU Sed.

git grep --name-only -IiE ^-\ latex$'\r'? content/{post,page} | \
xargs -n1 sed -i "s/^- latex/- LaTeX/I"

I tried to match

  1. a leading - using ^-
  2. a whitespace \ escaped by a backslash to avoid wrapping the special character below with double quotes
  3. the string “latex” (case-insensitive)
  4. the carriage return \r, which is represented by $'\r' in bash, for at most once (?)

I observed that wrapping $'\r' with "" would lead to no match.

[Read More]
Git  sed 

Conditional Batch File Editing

Adopted Mmark for Math Posts

Problem

During the adoption of Mmark for math posts on this blog, I had to insert markup: mmark at the last line of front matter of the source file of each math post.

Seek help

I separated this into two SO questions

  1. Sed conditional match and execute command with offset, and
  2. A question about AWK multiple line recognition.

Solution

From #1., I learnt the use of variables in AWK scripts. From #2, some users explained how these variables can be used for multi-line regex search.

[Read More]
awk  sed  Mmark