[SOLVED] Remove from text file only certain strings from another file 11 December 2021, 14:48:53 Hello i'm trying to remove certain strings written in a column from a text file (the output from lsmod) from another bigger text file (all the kernel modules) also organized in a column. So for example i have a big text file and a small text file. I need to remove from the bigger file one.txt (e.g 1234567) what's in the right file two.txt (357) so the output should look like three.txt(1246). This is just an example. Can't edit by hand as there are over 5000 modules. What can be used here, awk, sed? Tnx in advance in case someone has an idea how to solve this.ps: i need this as kernel modules always are added or changed once gets updated Last Edit: 12 December 2021, 22:57:38 by nous
Re: Remove from text file only certain strings from another file Reply #1 – 11 December 2021, 15:40:36 Wouldn't meld or kompare be suitable?
Re: Remove from text file only certain strings from another file Reply #2 – 11 December 2021, 16:27:12 Tried Kompare and diff but the output is huge and it gives also a huge output which is hard to process manually. Also i saw in kompare things that appeared as removed and at a later point same string appeared as added or vice-versa. So can't really find if was or not removed due to to size of the text file. Kompare seems to give all option except what i need and is very unintuitive to say the least. So the time to understand how kompare really works would exceed the time to process that file manually but still manually it's quite dumb to do it that way. Will try meld to see maybe i have more luck with that. Tnx for the suggestion!!!
Re: Remove from text file only certain strings from another file Reply #3 – 11 December 2021, 16:46:29 Yep tried meld and is even weaker than kompare. Says file to big something like that. Will try with cut command see if it covers this kind of situation.edit 1: Will try cat command and from the final txt file will try to remove duplicates . Hope i can get this done this way Last Edit: 11 December 2021, 16:58:51 by Surf3r
Re: Remove from text file only certain strings from another file Reply #4 – 11 December 2021, 17:12:56 Code: [Select]man grepthen typeCode: [Select]/^ +-f FILEand press Enter.Also of interest:Code: [Select]/^ +-voption.
Re: Remove from text file only certain strings from another file Reply #5 – 11 December 2021, 17:50:33 Wow that was pretty condensed 4 me looks like rocket science. I will try my method removing duplicate strings the only problem is i can remove duplicates but when i run the command it removes only one sample and not both XD. Think i will have to learn grep once and for all but for now looks kinda alien technology for me . Tnx anyway @strajder will get around this one way or another
Re: Remove from text file only certain strings from another file Reply #6 – 11 December 2021, 23:37:43 You probably need comm(1). 1 Likes
Re: Remove from text file only certain strings from another file Reply #7 – 12 December 2021, 00:56:44 Yeah comm makes more sense to me. Tried it with a smaller file for test and resulted 2 columns. First column from comm output is exactly what i needed, column 1 from first file minus column 2 from second file resulting exactly the difference, absolutely brilliant . Thank you very much @nous