简体   繁体   中英

Not able to Write single quotes into double quotes with a terminal

Im trying to make a file with the following line of code inside (ruby line)

puts File.read('/users') 

This is what I should be getting if I print that out.

The problem is that I'm not able to do that in the terminal. I tried a lot of things such as:

echo "puts File.read('/users')" > file_with_line.rb

echo puts File.read('/users') > file_with_line.rb

And other variants but none of them worked all of them give me an error or this output puts File.read(/users) without the single quotes.

It seems pretty easy and silly but I have not had success finding the solution. Thanks in advance.

You just have to close your double quotes:

echo "puts File.read('/users')" > file_with_line.rb

Here's a complete example:

bash-5.1$ echo "puts File.read('/users')" > file_with_line.rb
bash-5.1$ cat file_with_line.rb 
puts File.read('/users')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM