开发者

Call system to paste file together

开发者 https://www.devze.com 2023-02-13 16:23 出处:网络
file = [\"file1\",\"file2\",...].join(\" \") `paste \"#{file}\"` Hello, 开发者_如何学CI have this simple problem that has been bugging me for days. I want to use Ruby to select files to paste toget
file = ["file1","file2",...].join(" ")

`paste "#{file}"`

Hello, 开发者_如何学CI have this simple problem that has been bugging me for days. I want to use Ruby to select files to paste together, but when I use the above code, it returns saying that files are not found. If I run for a single file, e.g. paste file1, it works. Does someone see why the code isn't working?

Thanks in advance


It's because you quote #{file}. The thing that is executed is paste "file1 file2".

You probably want paste #{file} which would result in paste file1 file2. In your case, paste expects a file that is called "file1 file2" (filename with a space).

In other words, remove the double quotes in your second line.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号