sed
sed is a stream editor command using for
parsing and transforming text. -i This option
tells sed to edit files in place. It means the
Format:
s/pattern/replacement/flags
s: Stands for substitution/: Delimiters that separate the pattern and the replacement.
Example, convert (foo.html) to
(foo.html):
sed -i 's/\.html"/\.html"/g'\.html": The pattern to search for. Here:\.: matches a literal dot.md": matches the string
\.html": The replacement stringg: The global flag. It tells sed to replace all occurrences of the pattern in each line, not just for the first one.
Example, convert (foo.html#topic) to
(foo.html#topic):
sed -i 's/\.html\(#*\)/\.html\1/g' ${file%.*}.htmls/: Start the substitution command\.html\(#*\)/: The search pattern.\.matches a literal dot,mdmatches the string "md", and\(#*\)captures zero or more#characters.html\1/: The replacement pattern..htmlis the replacement string, and\1refers to the captured group of#characters.