
ファイルを使用してスクリプトを作成し、sed
そのスクリプトを再利用してテキストを翻訳するにはどうすればよいですか?たとえば、翻訳したいモールス符号ファイルがあり、sed
このスクリプトを使用して英語のテキストをモールス符号に変換する場合などです。
答え1
モス符号ファイルが何なのかわからないので(でも覚えていますね)前の質問)、私の考えはこんなスクリプトだと思います。
#!/bin/sh
# Some code that creates the sed script "translate.sed"
# goes here. We can't really know how to do this because
# we don't know what a "morse code file" is.
# Run the just-created script on a file which was
# given on the command line:
sed -f translate.sed "$1"
このスクリプトを呼び出すとdo_translate.sh
実行されます。
$ ./do_translate.sh text_file.txt
その中にはtext_file.txt
モス符号に翻訳したいファイルもあります。
sed
しかし、上記のスクリプトを実行するたびに生成したいのは奇妙です。おそらくtranslate.sed
一度作成して直接使用します。以前の回答で言及しました。。