Deleting the file only to all the directory and sub directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Deleting the file only to all the directory and sub directory
# 1  
Old 12-29-2008
Deleting the file only to all the directory and sub directory

I need the unix command or shell script to delete all the file in current directory and sub directory.
# 2  
Old 12-29-2008
make sure you are in the correct directory before issuing the command:

rm -rf *

will remove all files and directories.

use with care!!!
# 3  
Old 12-29-2008
Hi

rm -rf dirname
# 4  
Old 12-29-2008
Quote:
Originally Posted by kingganesh04
I need the unix command or shell script to delete all the file in current directory and sub directory.
This had been answered numerous number of times, please use the search facility of the forum before posting a question; sometimes your question might have been answered already.
# 5  
Old 12-30-2008
i want to remove only the files not the directory
# 6  
Old 12-30-2008
you have to write a script which will travel through all directories present in current directory and so on. then grep only for files and delete them.

-nilesh
# 7  
Old 12-30-2008
Quote:
Originally Posted by kingganesh04
i want to remove only the files not the directory
find files of type f and use xargs or exec to delete ( rm ) them

try searching the forums - for find, xargs, exec
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. AIX

Deleting a Directory

I have a directory under my home directory called: my work. I cannot delete this directory and I want to. If anyone needs additional information. Please let me know. Any help you can provide is greatly appreciated. (8 Replies)
Discussion started by: Nerdgirl1313
8 Replies

3. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

4. UNIX for Dummies Questions & Answers

Deleting a directory and zipping another directory

Hi Folks, I have a directory in unix that is /usr/local/pos contain the folowing directoreis ..that is dir1 dir2 dir3 now I want to delete only dir2 please advise how to remove the directory dir 2 ..that is rm command and how to use it , and second if I want to zip the dir3 please... (1 Reply)
Discussion started by: punpun66
1 Replies

5. Shell Programming and Scripting

Change to directory and search some file in that directory in single command

I am trying to do the following task : export ENV=aaa export ENV_PATH=$(cd /apps | ls | grep $ENV) However, it's not working. What's the way to change to directory and search some file in that directory in single command Please help. (2 Replies)
Discussion started by: saurau
2 Replies

6. Shell Programming and Scripting

Grepping file names, comparing them to a directory of files, and moving them into a new directory

got it figured out :) (1 Reply)
Discussion started by: sHockz
1 Replies

7. Shell Programming and Scripting

Deleting a type of file in a directory immediately it occurs

Hi All, I have to maintain few servers and in those servers in a specific directory some special jobs keeps on running ....... The directory is having many kind of files like.....acd*, hud*, rca*....bla bla bla....... My aim is that if due to any job-any time a file having initials like... (4 Replies)
Discussion started by: jitendra.pat04
4 Replies

8. Shell Programming and Scripting

Deleting the oldest file in a directory

Hey! I have found similar posts both here and on other sites regarding this, but I cannot seem to get my script to work. I want to delete the oldest file in a test directory if there are more than two files. My script is currently: #!/bin/bash MEPATH=/usr/local/bin/test FILECOUNT=`ls... (4 Replies)
Discussion started by: Immolation
4 Replies

9. Programming

problem deleting date-time stamped file in a directory

I have a number of files of the format filename.xfr_mmddyy_%H%M%S which i get in a specified directory daily. Now i want to search in the specified directory & delete the files which are more than 2 days old .So I use a command find $DIR/backup/* -ctime +2 -exec rm -f {} \; But after executing... (1 Reply)
Discussion started by: dharmesht
1 Replies

10. UNIX for Dummies Questions & Answers

Deleting A Directory!

This must be simple! How do you delete a directory that contains other files and directories?:confused: (2 Replies)
Discussion started by: firefinger
2 Replies
Login or Register to Ask a Question