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

Gantt Edmiston gantte at bellsouth.net
Tue Mar 16 11:22:41 EST 2004


Thanks Brett, but you didn't read the whole thing...

I tried quotes and it's not the chmod statement that's
failing.  It's the loop.  The shell is parsing each line,
seeing whitespace, and interpreting the two as
separate records.  It never get's to the chmod
line quoted or not, intact, as one line with a whitespace.


Albertson, Brett wrote:

> Gantt,
> You should be able to just put double quotes around it.  Ie.
>
> chmod o-w "$x"
>
> Brett Albertson           brett.albertson at stratech.com
> Strategic Technologies    voice: 919-379-8449     FAX: 919-379-8100
> Solaris Core, Enterprise, E10K, F15K certified.
>
>
> -----Original Message-----
> From: Gantt Edmiston [mailto:gantte at bellsouth.net]
> Sent: Tuesday, March 16, 2004 10:54 AM
> To: ncsa-discussion at ncsysadmin.org
> Subject: How-To question for the NC*SA brain trust...
>
>
> Here's a question for you all, something that should be much simpler than
> it has become.... I'll lay it out simply, the real situation is more
> detailed,
> but the example below will represent the problem that I have and 
> hopefully
> allow someone to provide the solution we need.
>
> Here is a brief extract from a 1200 line data file, named LIST,
> of fully qualified pathnames to files:
>
> /usr/local/foo bar/file1
> /usr/local/foo bar/file2
> /usr/local/foo bar/
>
> NOTE carefully, the whitespace in the directory name "foo bar".
> The actual filenames vary, the only consistent thing is that there is
> one space in the fully qualified pathnames.
>
> The task is to execute a "chmod o-w" on the 2 files and 1 directory
> shown above.
> Keep in mind, that real need is to do this on over 1200 of similar FQ
> pathnames.
> So the real task is to do this permissions change over a large number of
> files,
> thus the absolute need to do this programmatically.
>
> Normally, in bash, I would do:
>     for x in $(cat LIST)
>       do
>       chmod o-w $x
>       done
>
> But the shell has issues with the white space and the whole thing fails.
> It sees the section on the left as the first record and the second right
> of the whitespace as the second record and so on.
>
> I've tried quoting (single and double), I've tried quoting the paths in
> the datafile and I've tried adding back-slashes, all without positive
> effect.
>
> If someone can post a solution, I'd be most appreciative.
>
> TIA
>
> Gantt
> gantte at bellsouth.net
>
>
>
>
> _______________________________________________
> ncsa-discussion mailing list
> ncsa-discussion at ncsysadmin.org
> http://www.ncsysadmin.org/mailman/listinfo/ncsa-discussion
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.ncsysadmin.org/pipermail/ncsa-discussion/attachments/20040316/0180e4ca/attachment.htm


More information about the ncsa-discussion mailing list