2
는 내가 a_script.rb에 다음과 같은 한 :명령 대체를 사용하여 쉘 명령에 루비 스크립트의 출력을 인수로 전달하는 방법은 무엇입니까?
if ARGV.empty?
puts "string_without_spaces 'string with spaces'"
else
p ARGV
end
나는 실행하면 :
ruby a_script.rb `ruby a_script.rb`
나는 다음과 같은 출력을 얻을 :
["string_without_spaces", "'string", "with", "spaces'"]
하지만 그 대신, 내가하고 싶은 다음 출력 :
["string_without_spaces", "string with spaces"]
원하는 출력을 얻으려면 스크립트를 어떻게 변경합니까?
당신은 (사용할 수있는
"
및'
을 탈출한다 http://unix.stackexchange.com/questions/24954/when-is- xargs-needed # comment33593_24956) –