Skip to content

Instantly share code, notes, and snippets.

@nekomimi-daimao
Last active May 16, 2023 16:04
Show Gist options
  • Save nekomimi-daimao/711d3a3d8b3331eb33db80592dce9c92 to your computer and use it in GitHub Desktop.
Save nekomimi-daimao/711d3a3d8b3331eb33db80592dce9c92 to your computer and use it in GitHub Desktop.
行頭下げ.UTF-8/LFにのみ対応.ファイルの末尾に改行必須。
#!/bin/bash
array=(" " "「" "『")
formatted=""
while read -r line; do
if [ -n "$line" ] && [[ ! " ${array[*]} " =~ " "${line::1}" " ]]; then
formatted+=" "
fi
formatted+=$line
formatted+=$'\n'
done <"$1"
echo "$formatted" | sed '${/^$/d;}' >"$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment