Deleting Multiple Files With the Same Content


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Deleting Multiple Files With the Same Content
# 8  
Old 01-07-2010
Quote:
Originally Posted by Boris_yo

I want to remove all files named readme.html which contain words "Please contact us". How to do that?

Thanks!
Change the file name.

Code:
find -iname 'readme.html'

And change the grep pattern as

Code:
grep 'Please contact us'

And finally.,
Code:
find . -type f -name 'readme.html' -exec grep "Please contact us" {} \; -exec rm {} \;

# 9  
Old 01-08-2010
MySQL Thanks!

Thank you thegeek! Smilie
# 10  
Old 02-20-2010
Question -iname or -name?

Quote:
Originally Posted by thegeek
Change the file name.
Code:
find -iname 'readme.html'

And finally.,
Code:
find . -type f -name 'readme.html' -exec grep "Please contact us" {} \; -exec rm {} \;

So is it "-iname" or "-name"?

What does "-iname" and what does "-name"?
# 11  
Old 02-21-2010
It depends on what you need, if you want exactly (case sensitive ) readme.html, then use -name option.

Or you want the match to be case insensitive, then use -iname option which can actually match README.HTML, Readme.html and so on..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move multiple files 4rm Source to different target folders based on a series num in the file content

Dear Experts my scenario is as follows... I have one source folder "Source" and 2 target folders "Target_123456" & "Target_789101". I have 2 series of files. 123456 series and 789101 series. Each series has got 3 types of fiels "Debit", "Refund", "Claims". All files are getting... (17 Replies)
Discussion started by: phani333
17 Replies

2. Shell Programming and Scripting

Deleting multiple files off an ftp server once they have been downloaded

Hello, I have a server that I have to ftp files off and they all start SGRD and are followed by 6 numbers. SGRD000001 SGRD000002 SGRD000003 The script I have will run every 10 mins to pick up files as new ones will be coming in all the time and what I want to do is delete the files I have... (7 Replies)
Discussion started by: sph90457
7 Replies

3. Shell Programming and Scripting

Create Multiple files with content

I have a file details.csv and I need to create 5 files in same folder named as details1.csv,details2.csv,details3.csv,details4.csv,details5.csv along with contents of details.csv Thanks in Advance. (9 Replies)
Discussion started by: Prashanth B
9 Replies

4. UNIX for Dummies Questions & Answers

problem deleting multiple files using rm in UNIX

I'm baffled..... the system I work on creates files every Mon-Friday I'm trying to delete all files older than 30 days old from a Unix prompt, the command I'm using is: find /directory/ -mtime +30 -exec rm {} \; however it returns /directory/filename: 644 mode ? (y/n) for every file! ... (1 Reply)
Discussion started by: bquattrone
1 Replies

5. Shell Programming and Scripting

Deleting a column in multiple files that are comma separated

Hi, I have a directory that contains say 100 files named sequencially like input_1.25_50_C1.txt input_1.25_50_C2.txt input_1.25_50_C3.txt input_1.25_50_C4.txt .. .. .. input_1.25_50_C100.txt an example of the content in each of the file is: "NAME" "MEM.SHIP" "cgd1_10" "cgd1_10"... (9 Replies)
Discussion started by: Lucky Ali
9 Replies

6. Shell Programming and Scripting

renaming multiple files with first line of content

Hi , I want to rename multiple files with their first line bar the first character + the extension .qual. For the example below the filename should read 7180000000987.qual. I have trawled through different threads for 2 days and I don't seem to find anything I can adopt for this task :confused: ... (7 Replies)
Discussion started by: Bruno
7 Replies

7. Shell Programming and Scripting

deleting lines from multiple text files

I have a directory full of text data files. Unfortunately I need to get rid of the 7th and 8th line from them all so that I can input them into a GIS application. I've used an awk script to do one at a time but due to the sheer number of files I need some kind of loop mechanism to automate... (3 Replies)
Discussion started by: vrms
3 Replies

8. Shell Programming and Scripting

deleting file content

hallo..i work in c-shell and i want to delete the content of a file without deleting the file itself...commands like >filename or echo -n > filename didn't work....thanks in advance (2 Replies)
Discussion started by: tolkki
2 Replies

9. UNIX for Dummies Questions & Answers

Deleting all content in a file from command line

Hey guys, I'd like to delete all text within a text file without actually deleting the file. Is there a vi command I can do from my prompt without actually going into the file and doing a %d i think it is... to remove all the text inside? I want to add this to a cron job to erase all the data... (2 Replies)
Discussion started by: kingdbag
2 Replies

10. Shell Programming and Scripting

deleting multiple files through ftp

Hi, I have a situation where I need to delete multiple files from a folder once I connect to FTP server. I am using ftp script to get the files, number of files always vary from 1 to 100. once I get the files I need to delete all the files downloaded I am making a list of all the files... (4 Replies)
Discussion started by: mgirinath
4 Replies
Login or Register to Ask a Question