如何在 Git Bash 中编辑文本文件?
How do I edit a text file in Git Bash?
我正在使用 Windows 10,并且正在 Git 沉浸教程的实验 5 中,Git Bash 作为我的 shell。
我使用 echo 'puts "Hello, World"' > hello.rb
根据以下内容创建了 hello.rb 文件:
how to create a file with the cmd?
我要change our hello program to take an argument from the command line. Change the file to be:
puts "Hello, #{ARGV.first}!"
我想过使用 Sublime Text 来编辑文件,但我觉得不得不使用 Git Bash。我如何编辑 Git Bash 中的文件?
谢谢!
使用 GNU sed
替换文本。
sed -i "s/World/#{ARGV.first}\!/" hello.rb
cat hello.rb
puts "Hello, #{ARGV.first}!
https://www.gnu.org/software/sed/manual/sed.html#The-_0022s_0022-Command
编辑:或使用命令行编辑器,例如vi
或vim
。
The best way for me to edit a file in Git Bash is the command 'nano fileName.txt'. This command opens editing mode. After having your work done, press Ctrl + x. Then approve changes with "y" to finally exit nano.
我正在使用 Windows 10,并且正在 Git 沉浸教程的实验 5 中,Git Bash 作为我的 shell。
我使用 echo 'puts "Hello, World"' > hello.rb
根据以下内容创建了 hello.rb 文件:
how to create a file with the cmd?
我要change our hello program to take an argument from the command line. Change the file to be:
puts "Hello, #{ARGV.first}!"
我想过使用 Sublime Text 来编辑文件,但我觉得不得不使用 Git Bash。我如何编辑 Git Bash 中的文件?
谢谢!
使用 GNU sed
替换文本。
sed -i "s/World/#{ARGV.first}\!/" hello.rb
cat hello.rb
puts "Hello, #{ARGV.first}!
https://www.gnu.org/software/sed/manual/sed.html#The-_0022s_0022-Command
编辑:或使用命令行编辑器,例如vi
或vim
。
The best way for me to edit a file in Git Bash is the command 'nano fileName.txt'. This command opens editing mode. After having your work done, press Ctrl + x. Then approve changes with "y" to finally exit nano.