Page 1 of 1

Deleting specific lines from a text file

Posted: 22 Aug 2018 15:16
by goodywp
Hi all,

I had two text files one is whole and the other is part.txt

Here is the content of whole.txt
  • From
    \T501-08815-0103\Application_Signing\Signed_Schemes\QA_Infra-SL_0102_Signed_T3\

    .500006011000.S3S
    .500007011000.S3S
    .500008011000.S3S
    .500009011000.S3S
    .500010011000.S3S
    .500011011000.S3S
    .500012011000.S3S
    .500014011000.S3S
    .500015011800.S3S
    .500016011000.S3S
    .500028011201.S3S
    .500072011000.S3S
    .500129010200.S3S
    .500134010100.S3S
    .500142010100.S3S
    .500144010100.S3S
Here is the part.txt
  • 50001101
    50007201
Now my task is to remove two lines from whole.txt based upon the part.txt as search criteria

I have the below code to do the job.

Code: Select all

findstr /x /v /G: part.txt whole.txt >new.txt
it did not work and I know that because of the part.txt only have partial string matching the lines in whole.txt
If I modified the part.txt as below
.500011011000.S3S
.500072011000.S3S

run the above script again it shall delete the lines based upon the part.txt since /X Print lines that match exactly.
However, I only have part.txt as below
  • 50001101
    50007201
How can I do this deletion
Thanks

Re: Deleting specific lines from a text file

Posted: 22 Aug 2018 15:48
by aGerman
goodywp wrote:
22 Aug 2018 15:16
since /X Print lines that match exactly
You answered your own question.

Steffen

Re: Deleting specific lines from a text file

Posted: 22 Aug 2018 16:45
by Squashman
goodywp wrote:
22 Aug 2018 15:16
since /X Print lines that match exactly.
So what is the next logical step to test in your code?

You also asked this same question last month.
viewtopic.php?t=8727

Re: Deleting specific lines from a text file

Posted: 23 Aug 2018 06:15
by goodywp
My apologize for the duplicated questions! Sorry......!
Could you help me to remove it.
Thanks

Re: Deleting specific lines from a text file

Posted: 23 Aug 2018 08:27
by aGerman
Are you serious that you really need help to remove the /x from the command line? There are two possibilities, either use the DEL or the backspace key.

Steffen

Re: Deleting specific lines from a text file

Posted: 23 Aug 2018 12:28
by goodywp
aGerman wrote:
23 Aug 2018 08:27
Are you serious that you really need help to remove the /x from the command line? There are two possibilities, either use the DEL or the backspace key.

Steffen
I would be more than happy to see the two possibilities... :D
Thanks

Re: Deleting specific lines from a text file

Posted: 23 Aug 2018 12:43
by aGerman
I give you four weeks of absence from the forum. Time to think about ...

DosTips.com is not RentACoder.com. It's a support forum where volunteers spend their free time to help others. Free time that they don't want to waste. Of course they write some lines of code to give you an idea of how things work out. But they expect that you try to understand the code and that you ask in case something still isn't clear to you. They won't answer the same question again and again only if people are too lazy to learn from the answers they have been already given.

DosTips is not Facebook. If the only reason for your questions is to ask questions, thoughtlessly and only because you're bored, then you should rather use your time to learn.

The DosTips forum is no replacement for a tutorial and getting answers here does not protect you from learning by yourown. Batch consists of ~50 frequently used commands. Certainly not too much for you to learn in the past 12 months that you're here. The HELP command gives you an overview, the /? option passed to a specific command gives you extended informations (e.g. FINDSTR /?). Furthermore you'll find the command index on the top of this site, besides of a lot of more useful informations and example code.

Steffen