[英]Not able to Write single quotes into double quotes with a terminal
我試圖用下面的代碼行(紅寶石行)制作一個文件
puts File.read('/users')
如果我打印出來,這就是我應該得到的。
問題是我無法在終端中做到這一點。 我嘗試了很多東西,例如:
echo "puts File.read('/users')" > file_with_line.rb
echo puts File.read('/users') > file_with_line.rb
以及其他變體,但它們都不起作用,它們都給我一個錯誤,或者這個 output puts File.read(/users)
沒有單引號的情況下。
這似乎很容易和愚蠢,但我沒有成功找到解決方案。 提前致謝。
你只需要關閉你的雙引號:
echo "puts File.read('/users')" > file_with_line.rb
這是一個完整的例子:
bash-5.1$ echo "puts File.read('/users')" > file_with_line.rb
bash-5.1$ cat file_with_line.rb
puts File.read('/users')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.