LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-10-2008, 12:47 AM   #1
packets
Member
 
Registered: Oct 2005
Posts: 312

Rep: Reputation: 30
script in removing an entry in a long list of text


I have a thousand of lines consisting of email address. If I want to delete an entry lets say "admin@foo.com", is there a script where I can remove them.

Is there a command on how to do that?

Anyone can give an idea?
 
Old 09-10-2008, 01:06 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,295

Rep: Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358
sed -i -e 's/admin@foo.com//' file
 
Old 09-10-2008, 01:25 AM   #3
packets
Member
 
Registered: Oct 2005
Posts: 312

Original Poster
Rep: Reputation: 30
What if lists. Not just one. Should I do it like this:


LISTS=`cat /root/addresses.txt`

sed -i -e 's/$LISTS//' file

where addresses.txt consist of the ff:

nelson@foo.com
nelsonts@fee.com
nelsont@rjhtr.com
 
Old 09-10-2008, 02:06 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,295

Rep: Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358Reputation: 2358
Use a loop

Code:
for addr in `cat /root/addresses.txt`
do
    sed -i -e 's/$addr//' file
done
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
removing text shadows in kde; removing taskbar color gradient webazoid Linux - Software 1 04-11-2006 02:56 AM
userdel: error removing group/shadow entry essdeeay Linux - General 2 04-05-2006 05:58 AM
Removing LILO Entry DrEwMoNeY Slackware 3 03-16-2006 06:55 PM
netstat: removing an entry from it LinuxRam Linux - Networking 5 11-02-2004 07:07 AM
routing tables - removing entry zigmund555 Linux - Networking 2 10-03-2003 07:57 AM


All times are GMT -5. The time now is 12:23 PM.

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