Ruby のワンライナー スクリプトのどこに構文エラーがあるかを特定するのが困難です。
以下の Ruby スクリプトは Linux で動作します
ruby -e 'File.open("blahnew", "w") { |f| f.write(File.read("blah")) }'
Windows用に少し変更した後、このエラーメッセージが表示され続けました
C:\>ruby -e 'File.open("c:\testnew", "w") { |f| f.write(File.read("c:\test")) }'
'f' is not recognized as an internal or external command, operable program or batch file.
誰かが私の構文エラーを指摘してください。
解決 策 次の方法が機能します
ruby -e "File.open('c:/testnew', 'w') { |f| f.write(File.read('c:/test.txt')) }"
ruby -e "File.open('c:\testnew', 'w') { |f| f.write(File.read('c:\test.txt')) }"
ruby -e "File.open('c:\\testnew', 'w') { |f| f.write(File.read('c:\\test.txt')) }"
ありがとう!