Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to remove directory with subdirectories and files? Post 302118350 by the_learner on Monday 21st of May 2007 01:52:16 PM
Old 05-21-2007
I have a similar problem. I have a directory with *LOTS* of hidden files (beginning with a . )

In this case when I use rm -rf, I get the error:

rm: Unable to remove directory dir0: File exists

The thing is, I do not know where did all those files come from.. I think I did an nfs mount and something went wrong.. and these random files keep getting produced

-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsD355*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsD455*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsD845*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsD945*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDA45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDB45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDC45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDD45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDE45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDF45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE055*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE155*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE255*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE355*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE455*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE845*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE945*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsEA45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsEB45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsEC45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsED45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsEE45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsEF45*


even in dir0, rm .nfs* does not work.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to Remove Ctrl M characters in files from directories and its subdirectories

Hi, How to recursively remove Ctrl M characters in files from a directory and its sub directory ? I know unix2dos command is there but to remove in bunch of files ... ? Thanks (7 Replies)
Discussion started by: skdp
7 Replies

2. Shell Programming and Scripting

search files in a directory and its subdirectories

Hello my friends, I need to write a simple shell bad file :D that search and delete a file it's name 'Microsoft.txt' in the current directory and its subdirectories? So can you help to guide me how i can write this shell, Just give me the beginning :o thank you. (1 Reply)
Discussion started by: Net-Man
1 Replies

3. Shell Programming and Scripting

Replace a string in all files under a directory and its subdirectories

Hello Friends, I've been trying to write a script which finds a string and change it with another string. For this i want to search all files (with its arguments) under a spesific directory and its subdirectories. For example lets assume i want to replace an IP= 192.168.0.4 with another... (4 Replies)
Discussion started by: EAGL€
4 Replies

4. Shell Programming and Scripting

Bash: Gzip files in Directory and itīs Subdirectories

Hello dear Community, I have a task to wrtie a script which will gzip not zipped files in a directory and itīs subdirectories. I succeeded in gzippung the directory but not the subdirectories: #/bin/bash #go to the directory where to zip cd $1 #Zip unzipped files for i in `ls | xargs... (2 Replies)
Discussion started by: JamesCarter
2 Replies

5. Shell Programming and Scripting

Find files only in current directory...not subdirectories

Hi, I have to find files only in the current directory...not in the sub directories. But when I use Find command ... it searches all the files in the current directory as well as in the subdirectories. I am using AIX-UNIX machine.Please help..I tried to use maxdepth..but it is not working in AIX. (2 Replies)
Discussion started by: vsachan
2 Replies

6. Shell Programming and Scripting

Remove files from subdirectories given a list of filenames

Dear all, I have a dir structure like main_dir At_nn Ag_js Nf_hc .... mcd32 mgd43... mcd32 mgd43... mcd32 mgd43... and each subdir (e.g. mcd32, mgd43) contains files. Now, i... (15 Replies)
Discussion started by: yogeshkumkar
15 Replies

7. Shell Programming and Scripting

Help on Backing up all the files in the subdirectories under a parent directory

Hi, I am not too familiar with Unix scripting but I have to write code to find all the files under all the sub directories under a parent directory of unix location and move them to the corresponding Windows location. For eg: I have \home\sreenu\Files\ Under neath this I have multiple sub... (3 Replies)
Discussion started by: raj.sreenu
3 Replies

8. Shell Programming and Scripting

List files with *.i extension in a directory and all its subdirectories + 30days old then remove

I need to write a script to : list files with *.i extension in a directory and all its subdirectories + 30days old, save it in a file and then remove (2 Replies)
Discussion started by: lena keung
2 Replies

9. UNIX for Dummies Questions & Answers

Remove all the subdirectories except latest 5 inside any given directory

I Want to remove all the sub-directories except latest five in any given TGTDIR. Is there a way to do so without making a cd to TGTDIR? I have tried the following but not worked. Thank you. rm -rf `ls -t $TGTDIR | awk 'NR>5'` (20 Replies)
Discussion started by: Devendra Hupri
20 Replies

10. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies
MKDIR(1)						    BSD General Commands Manual 						  MKDIR(1)

NAME
mkdir -- make directories SYNOPSIS
mkdir [-pv] [-m mode] directory_name ... DESCRIPTION
The mkdir utility creates the directories named as operands, in the order specified, using mode rwxrwxrwx (0777) as modified by the current umask(2). The options are as follows: -m mode Set the file permission bits of the final created directory to the specified mode. The mode argument can be in any of the formats specified to the chmod(1) command. If a symbolic mode is specified, the operation characters ``+'' and ``-'' are interpreted rela- tive to an initial mode of ``a=rwx''. -p Create intermediate directories as required. If this option is not specified, the full path prefix of each operand must already exist. On the other hand, with this option specified, no error will be reported if a directory given as an operand already exists. Intermediate directories are created with permission bits of rwxrwxrwx (0777) as modified by the current umask, plus write and search permission for the owner. -v Be verbose when creating directories, listing them as they are created. The user must have write permission in the parent directory. DIAGNOSTICS
The mkdir utility exits 0 on success, and >0 if an error occurs. SEE ALSO
rmdir(1) COMPATIBILITY
The -v option is non-standard and its use in scripts is not recommended. STANDARDS
The mkdir utility is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. HISTORY
A mkdir command appeared in Version 1 AT&T UNIX. BSD
January 25, 1994 BSD
All times are GMT -4. The time now is 05:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy