Skip to content

Instantly share code, notes, and snippets.

@mitsuru793
Last active December 1, 2015 15:09
Show Gist options
  • Select an option

  • Save mitsuru793/8757e751fb76e34ab544 to your computer and use it in GitHub Desktop.

Select an option

Save mitsuru793/8757e751fb76e34ab544 to your computer and use it in GitHub Desktop.
質問形式を整形。空行も自動で挟んでくれます。
#!/bin/bash
# 【置換前】
# 〜ですか?
# はいそうです。
# これは違うのでは?
# いいえ、〜だからです。
# 【置換後】
# Q: 〜ですか?
# はいそうです。
#
# Q: これは違うのでは?
# いいえ、〜だからです。
LF=$(printf '\\\012_')
LF=${LF%_}
pattern="^\(.*\)?$"
replacement="Q: \1?"
sed "s/$pattern/$LF$replacement/g" | sed 1d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment