LinuxQuestions.org
Visit Jeremy's Blog.
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 07-19-2012, 06:41 AM   #1
m.praki
LQ Newbie
 
Registered: Jul 2012
Posts: 1

Rep: Reputation: Disabled
Delete multiple lines in a file based on the input text


I've a 15 lakh lines file. I need to delete 7000 lines in that file. Please see the sample file content below. All I have is the id (1st column). Based on the id, I have to delete the entire line in that file. The ID column will contain unique numbers(same id will not repeat).

Suppose, i have to delete 6666666 and 2222222 id lines. I would like to mass or bulk delete the 7000 lines based on the 7000 id i'm having. Can someone please suggest the command or script to delete the lines ?

1111111~first name2~last name2~address 2 123~test
6666666~first name2~last name2~address 2 123~test
2222222~first name2~last name2~address 2 123~test
5555555~first name2~last name2~address 2 123~test
 
Old 07-19-2012, 06:49 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,450

Rep: Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776
grep -v 6666666 inputfile > outputfile will do that for one line. But how do you want to specify 7000 ids? Probably in a file, line by line. In that case you can try grep -v -f idfile inputfile > outputfile
 
1 members found this post helpful.
  


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
delete top lines of a text file until a word is met njfhdsiue Linux - Software 3 07-07-2011 03:48 AM
[SOLVED] How to delete multiple lines in a file using perl yjy4321 Programming 14 04-21-2011 10:15 AM
delete multiple lines from file using shell script mech123 Linux - Newbie 4 06-09-2010 04:04 AM
Remove lines in a text file based on another text file asiandude Programming 10 01-29-2009 10:59 AM
how to delete two adjecent lines in a text file wangxinmco Linux - Newbie 3 01-10-2008 02:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:30 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