To Know this find and delete will work ???..


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers To Know this find and delete will work ???..
# 1  
Old 12-26-2007
To Know this find and delete will work ???..

All,

I have a question .

I have a directoy which have permision like

drwxrwxr-x 5 root cusr 8192 Dec 5 12:50 test

I dont have write permision to delete . inside the directory i am having many files . with permision like

$cd test
$ll
-rw-r----- 1 int intex 7705 Sep 4 15:59 xxxx


I want to know even though i am not having permision to delete the file will my find and delete work , ie will it delete the file

find test -name "xxxx" -exec rm -f -r 2> /dev/null "{}" ";"

Please let me know . I am in tedious situation.

Thanks,
Arun
# 2  
Old 12-26-2007
Further more if i have like this . Will it work

drwxrwxrwx 5 root cusr 8192 Dec 5 12:50 test

inside the directory i am having many files . with permision like

$cd test
$ll
-rw-r----- 1 int intex 7705 Sep 4 15:59 xxxx


find /test -name "xxxx" -exec rm -f -r 2> /dev/null "{}" ";"

Thanks,
Arun
# 3  
Old 12-26-2007
Have you tried "chown"?

Smilie Arun, there might be one of a couple of problems which would cause the command to fail.

To begin with, do you have access to the root account and its password?

If the answer to this is "yes", then you might want to change file ownership with the "chown" command. For an arbitrary file called "junk.txt", the sequence might run like this:

root@home/steve$$ ls -all
-rwxr-xr-x steve users 2048 12-07-07 junk.txt

root@home/steve$$ chown arun junk.txt
root@home/steve$$ ls -all
-rwxr-xr-x arun users 2048 12-07-07 junk.txt

As "arun", you may not be able to delete my file named "junk.txt", unless you are logged in as the file owner or as root, even if the file is in a directory where you have full read/write/execute permissions.

Does this help?

Last edited by Annatar; 12-26-2007 at 11:20 AM.. Reason: incorrect command result listing
Annatar
# 4  
Old 12-27-2007
Correction

Quote:
As "arun", you may not be able to delete my file named "junk.txt", unless you are logged in as the file owner or as root, even if the file is in a directory where you have full read/write/execute permissions.
if I am in a directory where I have full read/write/execute permissions, I should be able to delete the file even if I am not owner of that file.
Code:
rkumar@bdc4reteaix1w: /home/rkumar/unix_forum >touch file2del
rkumar@bdc4reteaix1w: /home/rkumar/unix_forum >ls -l file2del
-rw-r--r--   1 rkumar   dev               0 Dec 27 09:42 file2del
rkumar@bdc4reteaix1w: /home/rkumar/unix_forum >ls -ld
drwxrwxrwx   2 rkumar   dev            4096 Dec 27 09:42 .
rkumar@bdc4reteaix1w: /home/rkumar/unix_forum >su - oretail
oretail's Password:
[YOU HAVE NEW MAIL]
oretail@bdc4reteaix1w: /home/oretail >id
uid=205(oretail) gid=205(dev) groups=201(osdba),202(osoper),203(oinstall)
oretail@bdc4reteaix1w: /home/oretail >cd ~rkumar/unix_forum
oretail@bdc4reteaix1w: /home/rkumar/unix_forum >ls -l file2del
-rw-r--r--   1 rkumar   dev               0 Dec 27 09:42 file2del
oretail@bdc4reteaix1w: /home/rkumar/unix_forum >ls -ld
drwxrwxrwx   2 rkumar   dev            4096 Dec 27 09:42 .
oretail@bdc4reteaix1w: /home/rkumar/unix_forum >rm file2del
rm: Remove file2del? y
oretail@bdc4reteaix1w: /home/rkumar/unix_forum >ls -l file2del
ls: 0653-341 The file file2del does not exist.

# 5  
Old 12-27-2007
Thank you Anatar ..

But even if i am not the owner of the directory , if i am having W and X permision i am able to delete .

So please confirm that even though if i am not a woner of the file /Directory , but if the file /Directory has W and X permision can i delete that file /Directory .

Thanks,
Arun
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find command does not work on AIX 6.1

I have AiX system version 6.1 I wish the below find command to work on AiX system ksh shell and give similar output as this works fine on RedHat Linux centos 7. find /app/logs/fname1.out -printf "%M %u %TY-%Tm-%Td %TH:%TM %h/%f $(cksum<fname1.out | cut -d' ' -f1)\n" Output: -rw-r--r--... (7 Replies)
Discussion started by: mohtashims
7 Replies

2. Shell Programming and Scripting

Why regex pattern doesn't work in find?

$ find /opt/data_* -maxdepth 3 -type d -name "main*" 2> /dev/null /opt/data_025/maindblogs /opt/data_026/maindblogs /opt/data_027/maindblogs /opt/data_028/maindblogs $ find /opt/data_* -maxdepth 3 -type d -name "rvlogs*" 2> /dev/null /opt/data_002/prod/rvlogs2_archive... (4 Replies)
Discussion started by: urello
4 Replies

3. UNIX for Dummies Questions & Answers

find command in shell script doesn't work

Hello all, Something strange going on with a shell script I'm writing. It's trying to write a list of files that it finds in a given directory to another file. But I also have a skip list so matching files that are in that skip list should be, well uhm, skipped :) Here's the code of my... (2 Replies)
Discussion started by: StijnV
2 Replies

4. Shell Programming and Scripting

Delete all line breakes from File doesnt work

Hi, I have to delete all line breakes but it doenst work. $ sed -e 's/\\n//g' file.txt and the output contents still line breakes. What should I do? sincerely, Blackbox (3 Replies)
Discussion started by: Blackbox
3 Replies

5. AIX

Force delete key to work in aix ksh ?

I'm using AIX console over putty. I'm not very happy with default ksh command editing capabilities so I forced insert mode, arrow keys and command history by issuing: set -o emacs alias __D=`echo "\002"` alias __C=`echo "\006"` in emacs mode history works using ctrl+p, so only thing... (2 Replies)
Discussion started by: vilius
2 Replies

6. Shell Programming and Scripting

find options don't work in script

Hi, I'm trying to write a bash script to find some files. However it seems that the find command is not behaving the same way when the script is executed as it does when executed from the command line: Script extract: #!/bin/bash ... NEW="/usr/bin/find current/applications/ -name '*jar'... (3 Replies)
Discussion started by: mattd
3 Replies

7. Shell Programming and Scripting

find command with exec doesnt work

Hi There, I have a script which finds for log files and removes them if the file has changed in the last day. The script runs fine without errors. The log file is still there. So, I decided to print the find command and run the command outside the script. Getting "Incomplete statement" Can you... (6 Replies)
Discussion started by: funtochat2002
6 Replies

8. Shell Programming and Scripting

find & sed -i work fine. Now need -i workaround for old OS.

I have a script that does a search and replace on a tree using find, xargs and sed that looks something like this. find . -type f -print0 | xargs -0 sed -i 's/fromthis/tothis/g' Now this works fine on new versions on Linux but I need to make the script work on an old RAQ550 that has an older... (3 Replies)
Discussion started by: simonb
3 Replies

9. AIX

does find command always work ?!

hello ! can so help me ? here is my problem : a same command, using find command works on a server, but doesn't on another. I've been told, that it could be because of the file systems ... it's amazing ! can so explain, please ? thank you for your answer (1 Reply)
Discussion started by: chocolate
1 Replies

10. UNIX for Dummies Questions & Answers

How to find size of each subdirect? du -sk | ls doesn't work

Using solaris 2.5.1, and how can I get a summary of the size of each subdirectory, say for /export/home, all the users? usually I do a du -sk dirname but I have to manually type in each name, is there a better way? Thanks, (3 Replies)
Discussion started by: kymberm
3 Replies
Login or Register to Ask a Question