M
Mark Wilson
Hello,
I'm trying to do the following in Ruby using the Shell class:
From the command line, I would write this:
% grep -l PATTERN * | xargs mv --target-directory=DIRECTORY
Because I have many directories I want to visit in turn, I've tried the
following:
directories.each do |d|
shell = Shell.cd(d)
string = String.new
shell.transact do
string = shell.grep("-l", "PATTERN", "*") # => the '*' is not
expanded;
#
grep: *: No such file or directory
end
array = string.split
array.each { |e| File.move(e, "DIRECTORY") }
end
The above does not work. Does anyone have any insight (or alternate
ways to accomplish the same purpose in Ruby)?
Thank you.
Regards,
Mark
I'm trying to do the following in Ruby using the Shell class:
From the command line, I would write this:
% grep -l PATTERN * | xargs mv --target-directory=DIRECTORY
Because I have many directories I want to visit in turn, I've tried the
following:
directories.each do |d|
shell = Shell.cd(d)
string = String.new
shell.transact do
string = shell.grep("-l", "PATTERN", "*") # => the '*' is not
expanded;
#
grep: *: No such file or directory
end
array = string.split
array.each { |e| File.move(e, "DIRECTORY") }
end
The above does not work. Does anyone have any insight (or alternate
ways to accomplish the same purpose in Ruby)?
Thank you.
Regards,
Mark