grep, maybe

Ken D'Ambrosio ken at jots.org
Thu Oct 29 17:03:14 EDT 2009


Interesting point.  Three replies:
1) If you're mv'ing onto the same filesystem, the inodes will never
change, and it won't matter.
2) I imagine grep will only spit out a status (which is what the "&&"
parses) after it's finished running, though I'd have to verify that
empirically.
3) You can cheat, and do something like this:

cat "$i/*" | grep -l moe && mv "$i" /destpath || echo "mv didn't work: $?"

-Ken

On Thu, October 29, 2009 4:41 pm, Ben Scott wrote:
> On Thu, Oct 29, 2009 at 2:31 PM, Ken D'Ambrosio <ken at jots.org> wrote:
>
>> find -type d | while read i do grep moe "$i/*" && mv "$i"
>> /path/to/destination || echo "mv didn't work: $?"
>> done
>
> Hmmm, does the "find" execute concurrently with the "grep"?  If it
> does, then you're liable to confuse the hell out of "find" if you manage to
> move a directory which is a component of the path it's currently
> trasversing.
>
> -- Ben
> _______________________________________________
> gnhlug-discuss mailing list gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is believed to be clean.
>
>



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the gnhlug-discuss mailing list