How to filter txt file by string with using batch

Posted by Antediluvian on Stack Overflow See other posts from Stack Overflow or by Antediluvian
Published on 2010-05-26T12:36:28Z Indexed on 2010/05/26 12:41 UTC
Read the original article Hit count: 194

Filed under:

Hello guys I know this kind of problem will be very easy for you but I am total beginner in batch mode.

The question is how bat file code should look like to generate a new txt file from specific one .

for example .

I have report txt

Displaying status for license file: 7788@Server01

License Server: server01

                    License    In Use   Free
                    -------    ------   ----
                    Design*      1       6
                               (user1@host1)   127 server01 7788  4402

                  Assembly*      0       4

                       Pro       0      15

                     AdvSE       2       3
                              (user2@host2)  AdvSE server01 7788  2706
                              (user3@host3)  AdvSE server01 7788  1503

        SingleSite_License       1       3
                              (user4@host4)      SingleSite_License server01 7788  2003

      Intra_CLIENT_License        1       4
                              (user2@host2)      Intra_CLIENT_License server01 7788  2003

                       CAD       1      32
                              ^(user2@host2)     CAD server01 7788   501
* = License Extensions - Available only on startup.
^ = Borrowed License.
Press any key to continue . . . 

What I want to have in new file from this one are only lines :

SingleSite_License 3

Intra_CLIENT_License 9

but both SingleSite_License and Intra_Client_License should be taken from 1st found string -other are not necessary.

report txt can be different and licenses can be showed in different order .

if it not possible - other solution can be just only Free value will be written in new txt file - f.e 3 and 9 . so the last string in line which contains specific words

thank you for any tips

© Stack Overflow or respective owner

Related posts about batch