How-To question for the NC*SA brain trust...

John Strickler jstrick at mindspring.com
Tue Mar 16 17:13:20 EST 2004


(replying to myself)

Just wanted to make sure that it was clear in my sample code that "list" is the file containing the list of file names,
i.e.,

while read $x
do
     chmod o-w "$x"
done < listfile


-----Original Message-----
From: John Strickler <jstrick at mindspring.com>
Sent: Mar 16, 2004 5:11 PM
To: NC*SA Discussion List <ncsa-discussion at ncsysadmin.org>
Subject: Re: How-To question for the NC*SA brain trust...

Another simple approach is to use the shell's (bash or ksh) *read* command and put quotes around the variable

while read $x
do
     chmod o-w "$x"
done < list

This performs one chmod per file, unlike the xargs-type solutions, but has the advantage of being very tidy

-----Original Message-----
From: "Lance A. Brown" <brown9 at niehs.nih.gov>
Sent: Mar 16, 2004 4:47 PM
To: NC*SA Discussion List <ncsa-discussion at ncsysadmin.org>
Subject: Re: How-To question for the NC*SA brain trust...

What about something like:

cat $list | sed -e 's/^/"/' -e 's/$/"/' | xargs chmod o-w

This results in fewer chmod commands being executed.

I often use that sed statement while doing finds and whatnot in
directory spaces in samba shares, etc.

--[Lance]

-- 
Lance A. Brown
SysAdmin Task
LMIT ITSS Contract for 
National Institute of Environmental Health Sciences
919.361.5444x420

_______________________________________________
ncsa-discussion mailing list
ncsa-discussion at ncsysadmin.org
http://www.ncsysadmin.org/mailman/listinfo/ncsa-discussion

_______________________________________________
ncsa-discussion mailing list
ncsa-discussion at ncsysadmin.org
http://www.ncsysadmin.org/mailman/listinfo/ncsa-discussion



More information about the ncsa-discussion mailing list