
MS-DOS でファイルの各行の先頭に文字列を追加するにはどうすればよいですか?
サードパーティのコマンドがないので、AWKのようなものはありません(MSDOSで実行している人もいるようです)。
CMD(NT4以降、例えばXPやWin10などのWinNTベースのOSのcmdコンソール)には、forコマンドに多くのオプションがあることは知っています。 https://www.robvanderwoude.com/ntfor.php しかし、MS-DOSにはCMDのようなFORコマンドがありません。
見るhttps://web.archive.org/web/20100325172740/http://vfrazee.com/ms-dos/6.22/help/ そして https://web.archive.org/web/20100521101405/http://www.vfrazee.com/ms-dos/6.22/help/for.htm
では、MS-DOS ではどのように行うのでしょうか?
QBASICなしでは
答え1
「コマンドプロンプトからのバウンス」と呼ばれる方法。
MS-DOS の作者が想像もしなかった革新的な方法です。
CMDでも動作します
それは、Usenet やニュースグループの時代にも言及されていました。
C:\rara>dir /b
file.txt
C:\rara>type file.txt
house
fish
dog
C:\rara>ren file.txt file.bat
C:\rara>prompt the
thefile >file2
'house' is not recognized as an internal or external command,
operable program or batch file.
'fish' is not recognized as an internal or external command,
operable program or batch file.
'dog' is not recognized as an internal or external command,
operable program or batch file.
theprompt $p$g
C:\rara>type file2
thehouse
thefish
thedog
C:\rara>