Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 04-02-2004, 12:19 PM   #1
LQ Newbie
Registered: Feb 2004
Posts: 3

Rep: Reputation: 0
An easy way of deleting lines from multipe files?

I have multiple files that contain email addresses. One per line. I would like to remove a patiular email address from each file but I'm not sure the quickest way to do this.

If I do
grep *
I get

and so on.

Is there a way to somehow remove the email address from the with grep or should I try some other command?

Thank you for any help or suggestions.
Old 04-02-2004, 12:39 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

Try this:

1. Type in the following shell script# Declare a temp file
<= EXAMPLE: "vi":

# Make sure we can write to it (we'd be sad if we couldn't...)
touch $TMP
if [ ! -w $TMP ]; then
echo "WARNING: Unable to write to $TMP"
ls -l $TMP
exit 1

# OK: we're ready to remove the address "cow" using the tool "grep -v"
for i in file1 file2 file3; do
echo "Processing file $i..."
grep -v $ADDR $i > $TMP
mv $TMP $i

echo "Done."

2. Substitute your file names and the e-mail address you want to remove

3. Set the "execute" permissions on your script
<= EXAMPLE: "chmod +rw"

4. Run it
<= EXAMPLE: ./

Unfortunately, there's no one-line/1 command that I know if.

"hope that helps .. PSM
Old 04-02-2004, 12:58 PM   #3
LQ Newbie
Registered: Feb 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you very much for your help!!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting files in C monil Programming 4 03-13-2005 11:33 AM
Deleting files! a_priebe47 Slackware 6 10-17-2004 10:58 PM
Extracting Lines from files supreme_command Linux - Newbie 1 05-12-2004 05:21 AM
Deleting files ShakyJake Linux - Newbie 12 05-08-2003 04:07 PM
Deleting files Tingle Linux - Newbie 4 01-16-2003 05:19 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration