If I wanted to do the following things to all the files in a directory how could I do it. Make all the files in a directory and in its sub directories to hidden status and make a different directory and all its sub directories copy inhibit. I am really stumped and have been looking through the internet for the answer and no luck so far. I was thinking chmod but I think that is incorrect so please help me.
to make a file as a hidden file, it should be renamed with the "." in the front
filename : abc.txt
changed to : .abc.txt
so how would i go about renaming all the files in a directory and its sub dirctories to the same names with a . in front of them????
like a mv -R * .* or something so all the files keep there original name and just add a . infront????
you would need to do something like
find PRIVATE -type f | while read N
dir=`dirname $N`
base=`basename $N`
mv $N ${dir}/.${base}
done
I suggest you play around with the idea.
By the way, why not just make the directory 0700?
Also, simply making something hidden does not stop people reading it.
Ya porter you are right...
Better to use chmod....coz hiding file using . is not good solution ....
Thanks,
SWatantra
find PRIVATE -type f | while read N
dir=`dirname $N`
base=`basename $N`
mv $N ${dir}/.${base}
done
I am new to unix can you explain that code? Does it do this:
my Main directory is name in name is a file and a sub directory with a name like jon in that is a file will that code rename all of the files under it to hidden
PRIVATE is the path to the directory you want to affect.
find will enumerate through the files
dirname gets the directory name
basename gets the name without the directory
mv does the rename
Thank You. DO youhave any idea how to do the same thing but make all the files in directory and its sub directories to copy inhibit
chmod -R o-w,g-w directory
Means other people cannot read your files and hence cannot copy them.
You need to read up on UNIX file attributes and the secuity model.