From owner-freebsd-questions@FreeBSD.ORG Sat Mar 12 15:30:40 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BBF2716A4CE for ; Sat, 12 Mar 2005 15:30:40 +0000 (GMT) Received: from sccrmhc11.comcast.net (sccrmhc14.comcast.net [204.127.202.59]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1BF7543D58 for ; Sat, 12 Mar 2005 15:30:40 +0000 (GMT) (envelope-from emccoy@haystacks.org) Received: from [127.0.0.1] (c-24-98-109-41.hsd1.ga.comcast.net[24.98.109.41]) by comcast.net (sccrmhc14) with ESMTP id <2005031215303901400po6gre>; Sat, 12 Mar 2005 15:30:39 +0000 Message-ID: <42330B26.2040508@haystacks.org> Date: Sat, 12 Mar 2005 10:30:46 -0500 From: Eric McCoy User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Fafa Diliha Romanova References: <20050312115359.C14EF4BE6D@ws1-1.us4.outblaze.com> In-Reply-To: <20050312115359.C14EF4BE6D@ws1-1.us4.outblaze.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: FreeBSD Questions Subject: Re: chmod equivalent to find commands X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Mar 2005 15:30:40 -0000 Fafa Diliha Romanova wrote: > hello. > > i know there's an equivalent to these two find commands that > can be summed up in one chmod command: > > find . -type d -exec chmod 755 {} \; > find . -type f -exec chmod 644 {} \; > > it fixes my permissions ... > i haven't tested this yet but i think it's wrong: chmod -R u+rwX,a+rX > > what would be the best solution here? I would do it the same way you do, but with xargs instead: find . -type X -print0 | xargs -0 chmod XXX If you were feeling crazy and use sh: find . | while read path; do \ if [ -d "$path" ]; then chmod 755; else chmod 644; fi; \ done The latter is overkill, but the approach can be useful for nontrivial operations on systems that don't support -print0. It also has the benefit that you can do it over ssh without having to copy over a script, e.g. ssh user@host sh -s