Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chef - How to get the output of a command to a Ruby variable

Chef - How to get the output of a command to a Ruby variable

I have the below scenario where i grep for a file

command "ls /filder1 | grep .txt"

grep gives an output of the filename/filenames if they exists .,

I want to store the output to a ruby variable and use it in the template to generate a config file.

How do i do that ?

like image 362
Ravi D Avatar asked Jun 13 '13 08:06

Ravi D


1 Answers

Chef is Ruby so you can use backticks output = `find /filder1 | grep .txt`

like image 51
EnabrenTane Avatar answered Sep 28 '22 04:09

EnabrenTane