From: 7stud -- Date: 2011-08-15T14:25:42+09:00 Subject: Re: SFTP grep on foreach Sönke Buhr wrote in post #1016662: > Hi guys, > > I got > > Net::SFTP.start("somehost", "someuser", :password => "somepwd", > :keys => []) do |sftp| > sftp.dir.foreach("/upload/") do |e| > > > > What I want to do is to only parse the files in this given directory > which include "findme" and "foundme" for example. > > ls -l | grep "findme\|foundme" does the trick in a normal console. > > Is there any way to do this via sftp? > > Thanks in advance. > > Regards How about: sftp.dir.foreach("/path/to/directory") do |entry| if entry =~ /(found|find)me/ #do something here end end -- Posted via http://www.ruby-forum.com/.