find a word in a file then rm the file
Hi, I need to find a word in a file then remove it. I'm doing the following, but with no luck, thanks. 'find /var/spool/mqueue/ -type f|xargs grep toulon -exec rm {} \;' TIA
Patrick B. O'Brien wrote:
Hi,
I need to find a word in a file then remove it. I'm doing the following, but with no luck, thanks.
'find /var/spool/mqueue/ -type f|xargs grep toulon -exec rm {} \;'
TIA
Beware !!!! That will remove the file, not the word !!!!
I need to find a word in a file then remove it. I'm doing the following, but with no luck, thanks.
'find /var/spool/mqueue/ -type f|xargs grep toulon -exec rm {} \;'
find . -type f | xargs perl -i -p -e "s/$word//"; -- Steven Lembark 117 E. 55th Cognia NY, NY 10022 212 331 7844
-- "William A. Mahaffey III"
Patrick B. O'Brien wrote:
Hi,
I need to find a word in a file then remove it. I'm doing the following, but with no luck, thanks.
'find /var/spool/mqueue/ -type f|xargs grep toulon -exec rm {} \;'
faster way to delete the files: find . -type f | xargs grep -l $word | xargs rm -fv; exec will fork once for each word. -- Steven Lembark 117 E. 55th Cognia NY, NY 10022 212 331 7844
"Patrick B. O'Brien"
I need to find a word in a file then remove it. I'm doing the following, but with no luck, thanks.
'find /var/spool/mqueue/ -type f|xargs grep toulon -exec rm {} \;'
You want to delete all files that contain a word? Then I'd do rm -f $(find /var/spool/mqueue/ -type f|xargs grep -Fl toulon) If you want to remove the word from the file, see 'man sed'. Philipp
On Mon, 15 Nov 2004 11:35:54 -0800
"Patrick B. O'Brien"
Hi,
I need to find a word in a file then remove it. I'm doing the following, but with no luck, thanks.
'find /var/spool/mqueue/ -type f|xargs grep toulon -exec rm {} \;' This is dangerous since you are working with the email queue. An outgong email message usually contains 2 files, the first being the queue file, and starts with qf, the second is the email body and starts with df.
The above command is wrong.
find /var/spool/mqueue/ -type f -exec grep toulon {} \; -exec rm {} \;
This will look for each file containing the word, toulon, and remove it.
However it will only remove the file containing toulon. The queue file
may not be removed. As William pointed out you will remove the outgoing
email message data file. Make sure you turn off your MTA before doing
it.
--
Jerry Feldman
participants (5)
-
Jerry Feldman
-
Patrick B. O'Brien
-
Philipp Thomas
-
Steven Lembark
-
William A. Mahaffey III