08-17-2011
Delete File from Directories
Hi All,
I am trying to delete Files from a directory using the below command
find $/test/abc/xyz -mtime +30 -exec rm -f {} \;
The above command is deleting the files more than 30 days.
The problem is there are some subdirectories in xyz,
when i execute the above command its trying to delete the direcotires as well,
however its not having permission to do so, its giving an error saying
"No permission to delete the direcotry", So i am saved.
Is there a way i can exculde touching the directories and just delete the files.
Thanks in advance
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I need a hand with a script im trying to make. I have a directory
/usr/db/mail with a bunch of subdirectories such as
/usr/db/mail/domain1.com
/usr/db/mail/domain2.com etc. etc.
all of these directories in turn have sub directories of their own. What I need to do is search all of... (1 Reply)
Discussion started by: centrino
1 Replies
2. UNIX for Dummies Questions & Answers
I have a script that deletes obselete users from /etc/passwd then moves their home directories to another location. After 30 days, I need to delete the home directories that were moved to the new location. I would appreciate any ideas on how to delete the directories after the 30 days? (2 Replies)
Discussion started by: munch
2 Replies
3. UNIX for Dummies Questions & Answers
How to delete all subdirectories and contents?
oh, and if they are hard linked? (1 Reply)
Discussion started by: t4st33@mac.com
1 Replies
4. Shell Programming and Scripting
hi im so sorry i do not have time im doing an urgent cleanup.
I have to check on directories for example:
/export/home/itbr
/export/home/bscsmig
there are more but i have the list. how do i write a ksh script in for loop to check those directories and delete display a message if it was... (1 Reply)
Discussion started by: sbavanis
1 Replies
5. Shell Programming and Scripting
Hi
I have 10 directories.I want to delete all the dicrectories except the three recent directories based on timestamp.I am new to BASH can u help me? (1 Reply)
Discussion started by: newuser_25
1 Replies
6. Shell Programming and Scripting
Hi,
I have a requirement like,
I need to create the directory with date and time stap (i.e YYYYMMDDHMS) every day end need to delete the old directories which is 12 months old. I have tested with following script
cd /export/home/sbeeravo/; find . -type d -mtime +365 -exec rm -rf {} \;
... (2 Replies)
Discussion started by: ShirishaReddy
2 Replies
7. Shell Programming and Scripting
Hello All,
My shell script runs everyday to update certain database. Everytime the script runs it creates a directory, with "current date". These directories contain log and data files:
HOME_DIR/database_name/20120417/*
HOME_DIR/database_name/20120416/*... (6 Replies)
Discussion started by: ad23
6 Replies
8. Shell Programming and Scripting
Hello,
I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall:
I regularly need to delete files from many directories.
A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies
9. Red Hat
Hi,
I need to delete (remove) only directories.
How to achieve this? Plz help (4 Replies)
Discussion started by: karthick nath
4 Replies
10. Shell Programming and Scripting
Is there a way via some bash script or just cmd to find duplicate directories?
i have main folders:
TEST1
TEST2
In folder TEST1 is some amount of same folders as in folder TEST2
can be this done? i tried fdupe but it only search for dupe files not whle dirs
thx! (8 Replies)
Discussion started by: ZerO13
8 Replies
LEARN ABOUT OSF1
removeuser
removeuser(8) System Manager's Manual removeuser(8)
NAME
removeuser - Deletes user accounts interactively
SYNOPSIS
/usr/sbin/removeuser
DESCRIPTION
Security Note
If you have enhanced security installed on your system, you should use the dxaccounts command to remove users. See the Security manual and
the dxaccounts(8) reference page for more information.
The removeuser command is an interactive command for deleting user accounts from your system. It also gives the option of deleting the
user's home directory, files and mail. The command prompts you for specific information and informs you of its activity and error condi-
tions.
The removeuser command invokes /usr/sbin/userdel to delete the user account information from /etc/passwd and the hashed password database
(if present).
Only the superuser can execute this command.
The command performs the following tasks: Asks for a login name for the user to be deleted. Enter the login name. If this entry does not
exist in the /etc/passwd file, the command informs you of this and exits. If the entry does exist, the command continues. Displays the
entry for the user from the /etc/passwd file and asks if this is the entry you want to delete. If the answer to this query is no, the com-
mand indicates that the user was not deleted and then exits. If the answer to this query is yes, the command deletes the user's entry from
the /etc/passwd file and any occurrences of the user from the /etc/group file. It then states that the user was deleted. Searches several
administrative directories and files for occurrences of the user and informs you if they exist. If so, it suggests that you may want to
delete these occurrences when the command is finished. If no occurrences of the user are found in these directories and files, the command
indicates so. Asks if you want to delete the home directory, all subdirectories, and all mail files for the user. If the answer to this
query is no, the command indicates that the user's home directory was not deleted and then exits. If the answer to this query is yes, the
command continues.
As a precaution, the command reminds you that you should have backed up the files for the user before removing them if you do not
want to lose them. It then asks if you are sure that you want to delete the files for this user. If the answer to this query is
no, the command indicates that the user's home directory was not deleted and then exits. If the answer to this query is yes, the
command states that it is removing the user's home directory, its contents and the user's mail file. It then deletes these items.
At this point, the command ends.
NOTES
Users are advised to migrate to the /usr/sbin/userdel utility or the dxaccounts utility as this command may be removed in a future version
of the operating system.
EXAMPLES
Enter a login name to be removed or <Return> to exit: john This is the entry for (john) in the /etc/passwd file:
john:VSh6/xbMqPDcY:5006:15:sdf:/usr/users/john:
Is this the entry you want to delete (y/n)? y Working ... Entry for (john) removed. Searching relevant directories and files for (john)
... None found. Do you want to remove the home directory, all subdirectories, files, and mail for (john) (y/n)? y The files for (john)
will be lost if not backed up. Are you sure you want to remove these files (y/n)? y Deleting /usr/users/john Deleting
/usr/spool/mail/john
FILES
Specifies the command path Group file Password file
SEE ALSO
Commands: addgroup(8), adduser(8), dxaccounts(8), finger(1), mkpasswd(8), passwd(1), useradd(8), userdel(8), vipw(8)
Files: group(4), passwd(4)
removeuser(8)