Based on the permision in the dir can i delete the file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Based on the permision in the dir can i delete the file
# 1  
Old 01-08-2008
Based on the permision in the dir can i delete the file

All,

I am having a directory as

drwxrwsr-x 3 intermec intermec 10240 Jan 8 09:07 intermec

inside the directory . the files are like
cd
-rw-r----- 1 intrmc01 intermec 5226 Dec 2 15:03 AST07356.txt
-rw-r----- 1 intrmc01 intermec 5025 Dec 2 12:51 AST07363.txt
-rw-r----- 1 intrmc01 intermec 1607 Jan 2 16:17 AST08003.txt
-rw-r----- 1 intrmc01 intermec 7772 Jan 3 15:09 AST08004.txt
-rw-r----- 1 intrmc01 intermec 25125 Jan 4 14:57 AST08005.txt
-rw-r----- 1 intrmc01 intermec 20636 Jan 7 15:19 AST08008.txt

When i run the below command

find /intermec/ -name "*" -mtime +12 -exec rm -f -r 2> /dev/null "{}" ";"

The files are not deleted . it is showing as permision denied even though i have full permision on the directory . Why it is not removed .
Is that because files not having full permsion ???..

if yes can i over come that and remove the file by any other way ?..

but to note that i was also having a file inside the directory as
-rwxrwxrwx 1 intermec intermec 15209 Aug 1 16:27 AST07214.txt

i was not able to delete the is one also. What should i do in such a way that the files under the dirctory can be deleted

i know root will be able to remove . Apart from root can anyother can remove if so how can i found that.

Thanks,
Arun.

Last edited by arunkumar_mca; 01-08-2008 at 12:39 PM..
# 2  
Old 01-08-2008
Assuming you can do this manually, try modifying your find statement to this

find /intermec/ -type f -mtime +12 -exec rm -f {} 2> /dev/null \;

the * was unnecessary because you want all files anyway
the -type limits you to files.

And while quoting the simicolon may work, I am in the habit of using the escape to signify characters.
# 3  
Old 01-08-2008
Thanks AWK . But no hope i says permision denied ..
# 4  
Old 01-08-2008
Based on the directory information:

drwxrwsr-x 3 intermec intermec 10240 Jan 8 09:07 intermec


you must be either intermec, or part of the intermec group, to have permission to delete files. You can check your group priveledges by typing:

groups

I am not absolutely sure why the sticky bit in the directrory structure is set. - sorry.

The directory is open to the public - where they have read and search (able to change into the directory) but unable to create or delete files.
# 5  
Old 01-08-2008
thanks ..

Can u please confirm that if we change the directory permision like

drwxrwsrwx 3 intermec intermec 10240 Jan 8 09:07 intermec

will i be able to delete the files under the directory ??..

inside the directory the files has permsion like

-rw-r----- 1 intrmc01 intermec 5226 Dec 2 15:03 AST07356.txt
-rw-r----- 1 intrmc01 intermec 5025 Dec 2 12:51 AST07363.txt
-rw-r----- 1 intrmc01 intermec 1607 Jan 2 16:17 AST08003.txt
-rw-r----- 1 intrmc01 intermec 7772 Jan 3 15:09 AST08004.txt
-rw-r----- 1 intrmc01 intermec 25125 Jan 4 14:57 AST08005.txt
-rw-r----- 1 intrmc01 intermec 20636 Jan 7 15:19 AST08008.txt


also please help me know if i cahngethe permsion like i mentioned , will the delete operation can be performed by any user in any group ??..

will there file with above permision will be deleted .
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete lines from file based on condition

I want to keep last 2 days data from a file and want to delete others data from the file. Please help me. Sample Input # cat messages-2 Apr 15 11:25:03 test1 kernel: imklog 4.6.2, log source = /proc/kmsg started. Apr 15 11:25:03 test1 rsyslogd: (re)start Apr 16 19:42:03 test1 kernel:... (2 Replies)
Discussion started by: makauser
2 Replies

2. UNIX Desktop Questions & Answers

How to delete dir and sub dir

Guys, can you tell me how to delete directory and sub directory with files in them, for example: /system/upgrade/title/sub/var/vito/ I would like to delete 'title' and everything under it. Every sub dir contains files which need to be deleted as well. Thanks (1 Reply)
Discussion started by: DallasT
1 Replies

3. UNIX for Dummies Questions & Answers

windows partition file permision

I hava a windows NTFS partition on fedora15. The partitions auto-mounts to /media/Data ever starting of KDE. /dev/sda5 on /media/Data type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096) But I cant change the file permission in this... (1 Reply)
Discussion started by: vistastar
1 Replies

4. Shell Programming and Scripting

A script to find dir, delete files in, and then del dir?

Hello!! I have directories from 2008, with files in them. I want to create a script that will find the directoried from 2008 (example directory: drwxr-xr-x 2 isplan users 1024 Nov 21 2008 FILES_112108), delete the files within those directories and then delete the directories... (3 Replies)
Discussion started by: bigben1220
3 Replies

5. Shell Programming and Scripting

Delete block of text in one file based on list in another file

Hi all I currently use the following in shell. #!/bin/sh while read LINE do perl -i -ne "$/ = ''; print if !m'Using archive: ${LINE}'ms;" "datafile" done < "listfile" NOTE the single quote delimiters in the expression. It's highly likely the 'LINE' may very well have characters in it... (3 Replies)
Discussion started by: Festus Hagen
3 Replies

6. UNIX for Dummies Questions & Answers

file permision

Hello, I have a program which at run time creates a shell script and tries to redirect the output of the same to another file. both of the files are created at run time with different names. The problem is: the file it is redirecting to is being created as: -rw-r--r-- 1 root tech 69... (1 Reply)
Discussion started by: chandan.sharma
1 Replies

7. UNIX for Advanced & Expert Users

Delete File Based On Date

Hi Xpert Out There I have a lots of file in this path : -rw-r----- 1 oracle dba 3954176 Dec 21 2006 1_2008.dbf -rw-r----- 1 oracle dba 887808 Dec 21 2006 1_2009.dbf -rw-r----- 1 oracle dba 143872 Dec 21 2006 1_2010.dbf -rw-r----- 1 oracle dba ... (3 Replies)
Discussion started by: adzuanamir
3 Replies

8. Shell Programming and Scripting

Delete an empty file from dir.

Hi, I have an dir which has 50K file, some of them are empty. I want to delete the empty file from the dir. I am planning to use the following command. ls -l | grep " 0 " | awk '{print $9}' I can copy this to an file and then how do I use this file to delete the empty files.... Any help... (2 Replies)
Discussion started by: Script40
2 Replies

9. UNIX for Dummies Questions & Answers

File Permision

Hi, I want to know how the file permision should change to 755 automatically once the file is created. At the moment I do it explicitely by changing the permission mode to 755 using chmod command. The default permission for a new file in my system is 644 (-rw-r--r--). Thanks Saumya (6 Replies)
Discussion started by: sommyp
6 Replies

10. Shell Programming and Scripting

i want to delete a file based on existing file in a directory

hi i am having four files in a directory.like 1)sampleRej 2)exampleRej 3)samplemain 4)examplemain my requirement is i have to search for the rejected files (sampleRej,exampleRej) in a directory.if these files in that directory then i have to delete the main files... (3 Replies)
Discussion started by: srivsn
3 Replies
Login or Register to Ask a Question