テキスト バンドル ファイルを autokey ファイルに変換するコマンドを作成しようとしています。テキスト ファイルは次のようにフォーマットされます。
.abbr
This would be the replacement text for the line above in texter.
.day
Have a GREAt day!
.but
But some of the
information takes up multiple lines
.how
However all the abbreviations
start with a "." and
then x lines of text to be
それぞれを別のファイルに入れるか、略語とその置換テキストを次の形式で適切なフィールドに出力する必要があります。
"items": [
{
"usageCount": 0,
"omitTrigger": false,
"prompt": false,
"description": "description",
"abbreviation": {
"ignoreCase": false,
"wordChars": "[\\w]",
"immediate": false,
"abbreviation": "ABBREVIATION GOES HERE",
"backspace": true,
"triggerInside": false
},
"hotkey": {
"hotKey": null,
"modifiers": []
},
"phrase": "REPLACEMENT TEXT GOES HERE",
"modes": [
1
],
"showInTrayMenu": false,
"matchCase": false,
"filter": null,
"type": "phrase",
"sendMode": "kb"
awk で書式設定部分を処理できると確信していますが、適切な略語とその適切な置換テキストを取得するにはどうすればよいでしょうか。フォーマットできる個々のファイルに印刷するために思いついたのは次のとおりですが、close fに関するエラーが表示されます。
awk '/^\./ {f="$title\."++d} f{print > f} /^\./ {close f; f=""}'
このスクリプトは、私が書いたものでも機能しません。
#!/bin/sh
while read line
do
if echo $line | grep "^\."; then
line_no=`echo $line | awk -F "\." '{ print $2 }'
elif echo $line | grep "^\."; then
: #ignore
else
echo "$line" >> t2ak.$line_no
fi
done < Default.texter