Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 'mv' all files containing a certain string to a sub-directory



On Tue, Oct 31, 2006 at 12:59:15PM +0000, zzapper wrote:
> I want to 'mv' all files containing a certain
> string to a sub-directory.  Should be trivial
> but cant think how w/o creating a temporary file

For non-recursive behavior:

for file in *; do 
   grep -q "somestring" "$file" && mv "$file" "somedir"
done

Recursive behavior is more tricky, as mentioned
elsewhere in this thread.

-- 
JR



Messages sorted by: Reverse Date, Date, Thread, Author