
我想透過命令列製作簡單快速的程序,然後在 Firefox 中顯示結果...
我發現 Hello World 是學習它的最簡單方法:)
我該怎麼做?
答案1
作為單行?;)
echo '<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body>Hello World</body></html>' > index.html && xdg-open index.html
awk
也是命令列,因此
awk '//' <<<'<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body>Hello World</body></html>' > ~/tmp/index.html && xdg-open ~/tmp/index.html
糟糕的,但也有可能
echo "Hello World" > index.html && xdg-open index.html
答案2
vi
在控制台中輸入,按下i
並輸入 HTML 程式碼,輸入:w index.html
並按 Enter 確認,輸入:silent !firefox %
並享受!