Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [SOLVED] Remove from text file only certain strings from another file (Read 570 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

[SOLVED] Remove from text file only certain strings from another file

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
     

Re: Remove from text file only certain strings from another file

Reply #1
Wouldn't meld or kompare be suitable?

Re: Remove from text file only certain strings from another file

Reply #2
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
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


Re: Remove from text file only certain strings from another file

Reply #5
Wow that was pretty condensed 4 me :D 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 #7
Yeah  :D  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  8) . Thank you very much @nous