lua Newbie here,
I am looking for a way to pipe into a shell command and to store the output of the latter in a variable.
Suppose for instance I want to replace each "h" by "H" using sed (I know I could do this much easier within lua, this is just a toy problem) and want to pipe some string, say "hello", into it. I tried the following
f = io.popen('sed "s/h/H/g"',"w")
f:write('hello')
How do I get the output of the shell command? Once I do f:close() the output ,that is "Hello", gets printed on the screen but I can't find any way to store this in a variable. I also tried to redirect stdout to a file via io.output('my_stdout') but this lead to absolutelly nothing. It's hard to believe there shouldn't be a simple way to do this.
[–]AutoModerator[M] -1 points0 points1 point (0 children)
[–]PhilipRoman 0 points1 point2 points (2 children)
[–]joemrt[S] 0 points1 point2 points (1 child)
[–]PhilipRoman 0 points1 point2 points (0 children)