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

Frye, Matthew Matthew.Frye at rexhealth.com
Tue Mar 16 11:12:20 EST 2004


I had a similar situation once and ended up having to sed out the spaces,
reassign x to sed them back in, and then do chmod.  See below:

for x in $(cat LIST | sed s/\ //g ) 
do
x=$(echo $x | sed s/foobar/foo\ bar/g)
chmod o-w "$x"
done

	I tried it again, and it seems to work in this case.

Matt

-----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.



More information about the ncsa-discussion mailing list