LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Delete multiple lines in a file based on the input text (https://www.linuxquestions.org/questions/linux-newbie-8/delete-multiple-lines-in-a-file-based-on-the-input-text-4175417571/)

m.praki 07-19-2012 06:41 AM

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

pan64 07-19-2012 06:49 AM

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


All times are GMT -5. The time now is 01:19 PM.