Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Mar 2000 01:24:08 -0800
From:      Alfred Perlstein <bright@wintelcom.net>
To:        Joe Park <joepark@uclink4.berkeley.edu>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: very basic scripting questions
Message-ID:  <20000303012408.G14279@fw.wintelcom.net>
In-Reply-To: <4.2.0.58.20000302214315.00c0e100@uclink4.berkeley.edu>; from joepark@uclink4.berkeley.edu on Thu, Mar 02, 2000 at 09:55:07PM -0800
References:  <4.2.0.58.20000302214315.00c0e100@uclink4.berkeley.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
* Joe Park <joepark@uclink4.berkeley.edu> [000302 22:19] wrote:
> Hello,
> 
> I'm a newbie and I would like to ask you guys about scripting.  I need to 
> write a script that does chmod functions on files/directories listed at 
> separate file. (it doesn't have to be a argument.  the script already knows 
> the name of the file.)  For example, let say there is a file list_files.txt
> 
> list_files.txt :
> 750  /usr/src/tmp
> 750  /usr/src/lib
> 
> How do I feed each line to chmod?  (maybe with cat?)  How about if I need 
> to do some filtering, using regular expression?
> 
> I'm sorry to bother you guys with such a simple question.  Where can I find 
> more books about unix scripting?  I just bought "mastering regular 
> expression" from O'Reilley.  Is this a right choice?
> 
> Thank you for your help.

experiance will usually get you there eventually:

cut -f2 -d" " < list_files.txt | xargs chmod <yourflags>

-Alfred


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000303012408.G14279>