The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
unix questions ccp UNIX for Dummies Questions & Answers 4 07-22-2008 04:51 AM
some questions about UNIX 5.0.6 , Help me please mrr53 SCO 2 10-26-2007 11:53 PM
New To Unix - Some Questions! yahoo14 UNIX for Dummies Questions & Answers 1 06-07-2006 10:43 PM
Some UNIX Questions! JoeTheMan UNIX for Dummies Questions & Answers 1 01-18-2006 09:30 PM
I have a few questions about Unix.. SolidWing68 UNIX for Dummies Questions & Answers 1 08-11-2005 02:22 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-19-2007
Registered User
 

Join Date: Oct 2007
Posts: 6
Stumble this Post!
2 Unix questions

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.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-19-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,572
Stumble this Post!
to make a file as a hidden file, it should be renamed with the "." in the front

filename : abc.txt
changed to : .abc.txt
Reply With Quote
  #3 (permalink)  
Old 10-19-2007
Registered User
 

Join Date: Oct 2007
Posts: 6
Stumble this Post!
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????

Last edited by kaka; 10-19-2007 at 02:36 PM.
Reply With Quote
  #4 (permalink)  
Old 10-19-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Stumble this Post!
you would need to do something like


Code:
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.
Reply With Quote
  #5 (permalink)  
Old 10-20-2007
Registered User
 

Join Date: Feb 2007
Posts: 15
Stumble this Post!
Ya porter you are right...
Better to use chmod....coz hiding file using . is not good solution ....


Thanks,
SWatantra
Reply With Quote
  #6 (permalink)  
Old 10-20-2007
Registered User
 

Join Date: Oct 2007
Posts: 6
Stumble this Post!
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
Reply With Quote
  #7 (permalink)  
Old 10-20-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Stumble this Post!
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0