From owner-freebsd-questions@FreeBSD.ORG Sun Mar 13 10:33:12 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 B810F16A4CE for ; Sun, 13 Mar 2005 10:33:12 +0000 (GMT) Received: from webmail-outgoing.us4.outblaze.com (webmail-outgoing.us4.outblaze.com [205.158.62.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id 39BDE43D3F for ; Sun, 13 Mar 2005 10:33:12 +0000 (GMT) (envelope-from fteg@london.com) Received: from wfilter.us4.outblaze.com (wfilter.us4.outblaze.com [205.158.62.180])2DB8A180028F for ; Sun, 13 Mar 2005 10:33:12 +0000 (GMT) X-OB-Received: from unknown (205.158.62.49) by wfilter.us4.outblaze.com; 13 Mar 2005 10:33:12 -0000 Received: by ws1-1.us4.outblaze.com (Postfix, from userid 1001) id 1A2E84BE6D; Sun, 13 Mar 2005 10:33:12 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received: from [127.0.0.1] by ws1-1.us4.outblaze.com with http for fteg@london.com; Sun, 13 Mar 2005 05:33:12 -0500 From: "Fafa Diliha Romanova" To: "Loren M. Lang" Date: Sun, 13 Mar 2005 05:33:12 -0500 X-Originating-Ip: 127.0.0.1 X-Originating-Server: ws1-1.us4.outblaze.com Message-Id: <20050313103312.1A2E84BE6D@ws1-1.us4.outblaze.com> cc: freebsd-questions@freebsd.org 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: Sun, 13 Mar 2005 10:33:12 -0000 I think it's really best that I stick to my find commands. chmod -R u=3DrwX,go=3DrX . worked really fast but it also made all my files executable. Bad idea, asking for such a command. By the way, umask 022? What is meant by that? ----- Original Message ----- From: "Loren M. Lang" To: "Giorgos Keramidas" Subject: Re: chmod equivalent to find commands Date: Sun, 13 Mar 2005 02:15:00 -0800 >=20 > On Sat, Mar 12, 2005 at 09:53:02PM +0200, Giorgos Keramidas wrote: > > On 2005-03-12 10:30, Eric McCoy wrote: > > >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 {} \; > > > > Uhm, why? Even if that were possible, isn't clarity more important that > > stuffing as many actions as possible in one line? > > > > What you list above is similar to the way I use for changing the > > permissions of files/dirs and it works all the time. > > > > There's no reason to try to write one, long, complicated command just > > for the sake of making it one command instead of two. Otherwise, you > > may as well do more complex stuff like: >=20 > Summing it up into one command does not neccessarily mean it's longer or > more complicated. I use the following command all the time to fix > permissions similar to what he seems to be doing. Though it's not > technically equivalent, it's probably all he needs. >=20 > chmod -R u=3DrwX,go=3DrX . >=20 > My umask of 022 simplifies the command to the following: >=20 > chmod -R =3DrwX . >=20 > > > > find . | while read line; do > > mode=3D'' > > [ -d "${line}" ] && mode=3D0755 > > [ -f "${line}" ] && mode=3D0644 > > > > [ -n "${mode}" ] && echo "chmod ${mode} \"${line}\"" > > done | sh > > > > But this is getting quickly very difficult to remember easily and repeat > > consistently every time you want to do something similar :) > > > > >> 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 > > > > This is an excellent way to do this, IMHO. > > > > > If you were feeling crazy and use sh: > > > > > > find . | while read path; do \ > > > if [ -d "$path" ]; then chmod 755; > > > else chmod 644; fi; \ > > > done > > > > I guess you meant to write: > > > > find . | while read path; do \ > > if [ -d "$path" ]; then chmod 755 "${path}"; > > else chmod 644 "${path}"; fi; \ > > done > > > > Otherwise, many chmod failures are the only result. > > > > But this has a minor buglet. It will change everything that is not a > > directory to mode 0644. This mode is ok for files, but it may not be ok > > (or it may even fail) for other stuff (symbolic links, for instance). > > > > - Giorgos > > > > _______________________________________________ > > freebsd-questions@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd= .org" >=20 > -- > I sense much NT in you. > NT leads to Bluescreen. > Bluescreen leads to downtime. > Downtime leads to suffering. > NT is the path to the darkside. > Powerful Unix is. >=20 > Public Key: ftp://ftp.tallye.com/pub/lorenl_pubkey.asc > Fingerprint: CEE1 AAE2 F66C 59B5 34CA C415 6D35 E847 0118 A3D2 >=20 << 2.dat >> --=20 ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm