delete recursively contents of folders


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers delete recursively contents of folders
# 1  
Old 08-26-2009
Java delete recursively contents of folders

hi,

I've a folder structure like :

/home/project/LIBNAMEA/FILE1
/home/project/LIBNAMED/FILE2
/home/project/LIBNAMEC/FILE3
/home/project/LIBNAMED/FILE4
/home/project/LIBNAMEX/FILE5

(there is no relation in the letters after the project/ )

and i need to delete the files keeping the structure of folders.

any help?

thx in advance

jtmartins
# 2  
Old 08-26-2009
Hi.

Code:
find /home/project/LIBNAME* -type f -exec rm -f {} \;

Replace "rm -f" with "ls -l" to test it before you run it!
# 3  
Old 08-27-2009
for file in `find /home/project/ -type f`
do
rm -f $file
done
# 4  
Old 08-27-2009
eve0094@host:/batch/sas/ODW $ find /batch/sas/ODW/libname/* -type f -exec ls -l {} \ ;

find: 0652-018 An expression term lacks a required parameter.

any help ?
# 5  
Old 08-27-2009
It was LIBNAME* not LIBNAME/* because in your original post, you had many directories starting with LIBNAME
# 6  
Old 08-27-2009
find: 0652-019 The status on /batch/sas/ODW/LIBNAME* is not valid.

Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

recursively going through folders and subdirectorys and running delete from crontab

Hio, So I have a crontab delete of older files setup. This script works fine if I run them by each individual directory. Problem is there are so many thousands of files and hundreds of directories and sub directories that I need to recursively have it go through and delete files by directory... (2 Replies)
Discussion started by: vsekvsek
2 Replies

2. Shell Programming and Scripting

How best to remove certain characters from filenames and folders recursively

hello, I'm trying to figure out which tool is best for recursively renaming and files or folders using the characters \/*?<>| in their name. I've tried many examples that use Bash, Python and Perl, but I'm not much of a programmer I seem to have hit a roadblock. Does anyone have any... (15 Replies)
Discussion started by: prometheon123
15 Replies

3. Shell Programming and Scripting

ftp script to copy folders recursively

hi all I want a script that will use ftp to copy folder and sub folders from source server to current server. if i use -r switch then it just copies folders for 5 level. (1 Reply)
Discussion started by: kashif.live
1 Replies

4. UNIX for Advanced & Expert Users

Delete empty directories recursively - HP-UX

Hi, I want to delete all empty directories in a long directore tree structure. I want to use that from a script that will run on HP-UX 11. My definition of empty directory is that there is no regular file under it and directly beneath it. To elaborate, I have below directories. /app/dev/java... (14 Replies)
Discussion started by: asutoshch
14 Replies

5. UNIX for Dummies Questions & Answers

Recursively dump all sub-dirs contents?

Hi, I have a dir structure that has many many subdirs, I would like to dump all the files from al the sub-dirs into a single directory? Can someone tell me the mv command that would do this please? before example: datadir/ datadir/datajan/jan.dat datadir/datafeb/feb.dat after example:... (1 Reply)
Discussion started by: CountryGent
1 Replies

6. UNIX for Advanced & Expert Users

Recursively delete only specified directories with given pattern

Hi All, We have a requirement to recursively delete the directories and its subdirectories older than 60 days based on timestamp (folder creation timestamp)under certain directory. However it has some specific requirements. The directories will continue to be there upto any depth. the... (0 Replies)
Discussion started by: rcvasu
0 Replies

7. Shell Programming and Scripting

RSYNC script to transfer folders recursively without overwriting via FTP

Hi all, I would need a bash script to sync/transfer folders recursively via FTP/RSYNC (I initially planned to use FTP but I heard RSYNC would fit a lot better for this job(?)) The situation: 3 different Linux servers 1. source 2. destination - Samba 3. Server where the script runs on ... (2 Replies)
Discussion started by: thibautp
2 Replies

8. Shell Programming and Scripting

Delete all injected code recursively

Recently all of the php files on my server got injected with some dating site code and I'm trying to get rid of it all at once. I've tried using sed but I don't know how to escape it correctly because I don't really know what I'm doing. Could you guys help me with the syntax? find ./* -type f... (2 Replies)
Discussion started by: ISOcrates
2 Replies

9. Shell Programming and Scripting

recursively delete the text between 2 strings from a file

i have 200000bytes size of a unix file i need to delete some text between two strings recursively using a loop with sed or awk . these two strings are : 1st string getting from a file :::2 nd string is fi...its constant . can anyone help me sed -n'/<1 st string >/,/fi/' <input_filename> is the... (2 Replies)
Discussion started by: santosh1234
2 Replies

10. Shell Programming and Scripting

delete files recursively in the specified directory

I have to write a shell script which can delete all the files and directories recursively inside the specified directory but should not delete the specified directory. Please some body help me in writing the script. (3 Replies)
Discussion started by: deepthi.s
3 Replies
Login or Register to Ask a Question