ヘッダー構文が であるマークダウン ページがあります!!!
。例えば:
!!! Better Heading
This section has a sub-heading
!! Sub-Heading one
!!! Can't think of another one
umm...
!!! A Great Heading
Some text here
テキストのブロックをアルファベット順にソートしたいと思います!!!
。!!!
そうする方法はありますか?
これを試して :
perl -ne 's/^(?!!!!)/###/g; print;' file | sed ':a;N;$!ba;s/\n###/###/g' | sort | sed 's/###/\n/g'
最初にすべての非ヘッダー行をマークします:
perl -ne 's/^(?!!!!)/###/g; print;' file
!!! Better Heading
###This section has a sub-heading
###!! Sub-Heading one
###
!!! Can't think of another one
###umm...
###
###
!!! A Great Heading
###Some text here
次に、\n
これらの行の前に削除します。
perl -ne 's/^(?!!!!)/###/g; print;' file | sed ':a;N;$!ba;s/\n###/###/g'
!!! Better Heading###This section has a sub-heading###!! Sub-Heading one###
!!! Can't think of another one###umm...######
!!! A Great Heading###Some text here
次に、マーカーを並べ替えて次のように置き換えます\n
。
perl -ne 's/^(?!!!!)/###/g; print;' file | sed ':a;N;$!ba;s/\n###/###/g' | sort | sed 's/###/\n/g'
!!! A Great Heading
Some text here
!!! Better Heading
This section has a sub-heading
!! Sub-Heading one
!!! Can't think of another one
umm...